########### next target ###############
set(oxygen_PART_SRCS
- animations/oxygenanimations.cpp
- animations/oxygenanimationdata.cpp
- animations/oxygenbaseengine.cpp
- animations/oxygendockseparatordata.cpp
- animations/oxygendockseparatorengine.cpp
- animations/oxygenenabledata.cpp
- animations/oxygengenericdata.cpp
- animations/oxygenheaderviewdata.cpp
- animations/oxygenheaderviewengine.cpp
- animations/oxygenmdiwindowdata.cpp
- animations/oxygenmdiwindowengine.cpp
- animations/oxygenmenubardata.cpp
- animations/oxygenmenubarengine.cpp
- animations/oxygenmenudata.cpp
- animations/oxygenmenuengine.cpp
- animations/oxygenprogressbardata.cpp
- animations/oxygenprogressbarengine.cpp
- animations/oxygenscrollbardata.cpp
- animations/oxygenscrollbarengine.cpp
- animations/oxygensliderdata.cpp
- animations/oxygensliderengine.cpp
- animations/oxygenspinboxdata.cpp
- animations/oxygenspinboxengine.cpp
- animations/oxygensplitterengine.cpp
- animations/oxygentabbardata.cpp
- animations/oxygentabbarengine.cpp
- animations/oxygentoolbardata.cpp
- animations/oxygentoolbarengine.cpp
- animations/oxygentoolboxengine.cpp
- animations/oxygenwidgetstatedata.cpp
- animations/oxygenwidgetstateengine.cpp
debug/oxygenwidgetexplorer.cpp
- transitions/oxygencomboboxdata.cpp
- transitions/oxygencomboboxengine.cpp
- transitions/oxygenlabeldata.cpp
- transitions/oxygenlabelengine.cpp
- transitions/oxygenlineeditdata.cpp
- transitions/oxygenlineeditengine.cpp
- transitions/oxygenstackedwidgetdata.cpp
- transitions/oxygenstackedwidgetengine.cpp
- transitions/oxygentransitiondata.cpp
- transitions/oxygentransitions.cpp
- transitions/oxygentransitionwidget.cpp
oxygenblurhelper.cpp
oxygenframeshadow.cpp
oxygenmdiwindowshadow.cpp
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenanimationdata.cpp
-// base class data container needed for widget animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimationdata.h"
-#include "oxygenanimationdata.moc"
-
-namespace Oxygen
-{
-
- qreal AnimationData::OpacityInvalid = -1;
- int AnimationData::_steps = 0;
-
- //_________________________________________________________________________________
- void AnimationData::setupAnimation( const Animation::Pointer& animation, const QByteArray& property )
- {
-
- // setup animation
- animation.data()->setStartValue( 0.0 );
- animation.data()->setEndValue( 1.0 );
- animation.data()->setTargetObject( this );
- animation.data()->setPropertyName( property );
-
- }
-
-}
+++ /dev/null
-#ifndef oxygen_animationdatah
-#define oxygen_animationdatah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenanimationdata.h
-// base class data container needed for widget animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include <QtCore/QEvent>
-#include <QtCore/QObject>
-#include <QtCore/QWeakPointer>
-#include <QtGui/QWidget>
-
-#include <cmath>
-
-#include "oxygenanimation.h"
-
-namespace Oxygen
-{
-
- //! base class
- class AnimationData: public QObject
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- AnimationData( QObject* parent, QWidget* target ):
- QObject( parent ),
- _target( target ),
- _enabled( true )
- { Q_ASSERT( _target ); }
-
- //! destructor
- virtual ~AnimationData( void )
- {}
-
- //! duration
- virtual void setDuration( int ) = 0;
-
- //! steps
- static void setSteps( int value )
- { _steps = value; }
-
- //! enability
- virtual bool enabled( void ) const
- { return _enabled; }
-
- //! enability
- virtual void setEnabled( bool value )
- { _enabled = value; }
-
- //! target
- const QWeakPointer<QWidget>& target( void ) const
- { return _target; }
-
- //! invalid opacity
- static qreal OpacityInvalid;
-
- protected:
-
- //! setup animation
- virtual void setupAnimation( const Animation::Pointer& animation, const QByteArray& property );
-
- //! apply step
- virtual qreal digitize( const qreal& value ) const
- {
- if( _steps > 0 ) return std::floor( value*_steps )/_steps;
- else return value;
- }
-
- //! trigger target update
- virtual void setDirty( void ) const
- { if( _target ) _target.data()->update(); }
-
- private:
-
- //! guarded target
- QWeakPointer<QWidget> _target;
-
- //! enability
- bool _enabled;
-
- //! steps
- static int _steps;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenanimations.cpp
-// container for all animation engines
-// -------------------
-//
-// Copyright (c) 2006, 2007 Riccardo Iaconelli <riccardo@kde.org>
-// Copyright (c) 2006, 2007 Casper Boemann <cbr@boemann.dk>
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimations.h"
-#include "oxygenanimations.moc"
-#include "oxygenpropertynames.h"
-#include "oxygenstyleconfigdata.h"
-
-#include <QtGui/QAbstractItemView>
-#include <QtGui/QComboBox>
-#include <QtGui/QDial>
-#include <QtGui/QHeaderView>
-#include <QtGui/QLineEdit>
-#include <QtGui/QMainWindow>
-#include <QtGui/QMdiSubWindow>
-#include <QtGui/QScrollBar>
-#include <QtGui/QSpinBox>
-#include <QtGui/QSplitterHandle>
-#include <QtGui/QTextEdit>
-#include <QtGui/QToolBar>
-#include <QtGui/QToolBox>
-#include <QtGui/QToolButton>
-#include <QtGui/QGroupBox>
-
-#include <KDebug>
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- Animations::Animations( QObject* parent ):
- QObject( parent )
- {
-
- _widgetEnabilityEngine = new WidgetStateEngine( this );
- _spinBoxEngine = new SpinBoxEngine( this );
- _comboBoxEngine = new WidgetStateEngine( this );
- _toolButtonEngine = new WidgetStateEngine( this );
- _toolBoxEngine = new ToolBoxEngine( this );
-
- registerEngine( _splitterEngine = new SplitterEngine( this ) );
- registerEngine( _dockSeparatorEngine = new DockSeparatorEngine( this ) );
- registerEngine( _headerViewEngine = new HeaderViewEngine( this ) );
- registerEngine( _widgetStateEngine = new WidgetStateEngine( this ) );
- registerEngine( _lineEditEngine = new WidgetStateEngine( this ) );
- registerEngine( _progressBarEngine = new ProgressBarEngine( this ) );
- registerEngine( _menuBarEngine = new MenuBarEngineV1( this ) );
- registerEngine( _menuEngine = new MenuEngineV1( this ) );
- registerEngine( _scrollBarEngine = new ScrollBarEngine( this ) );
- registerEngine( _sliderEngine = new SliderEngine( this ) );
- registerEngine( _tabBarEngine = new TabBarEngine( this ) );
- registerEngine( _toolBarEngine = new ToolBarEngine( this ) );
- registerEngine( _mdiWindowEngine = new MdiWindowEngine( this ) );
- }
-
- //____________________________________________________________
- void Animations::setupEngines( void )
- {
-
- // animation steps
- AnimationData::setSteps( StyleConfigData::animationSteps() );
-
- {
- // default enability, duration and maxFrame
- bool animationsEnabled( StyleConfigData::animationsEnabled() );
-
- // enability
- _widgetEnabilityEngine->setEnabled( animationsEnabled && StyleConfigData::genericAnimationsEnabled() );
- _widgetStateEngine->setEnabled( animationsEnabled && StyleConfigData::genericAnimationsEnabled() );
- _comboBoxEngine->setEnabled( animationsEnabled && StyleConfigData::genericAnimationsEnabled() );
- _toolButtonEngine->setEnabled( animationsEnabled && StyleConfigData::genericAnimationsEnabled() );
- _toolBoxEngine->setEnabled( animationsEnabled && StyleConfigData::genericAnimationsEnabled() );
- _lineEditEngine->setEnabled( animationsEnabled && StyleConfigData::genericAnimationsEnabled() );
- _splitterEngine->setEnabled( animationsEnabled && StyleConfigData::genericAnimationsEnabled() );
- _scrollBarEngine->setEnabled( animationsEnabled && StyleConfigData::genericAnimationsEnabled() );
- _sliderEngine->setEnabled( animationsEnabled && StyleConfigData::genericAnimationsEnabled() );
- _spinBoxEngine->setEnabled( animationsEnabled && StyleConfigData::genericAnimationsEnabled() );
- _tabBarEngine->setEnabled( animationsEnabled && StyleConfigData::genericAnimationsEnabled() );
- _dockSeparatorEngine->setEnabled( animationsEnabled && StyleConfigData::genericAnimationsEnabled() );
- _headerViewEngine->setEnabled( animationsEnabled && StyleConfigData::genericAnimationsEnabled() );
- _mdiWindowEngine->setEnabled( animationsEnabled && StyleConfigData::genericAnimationsEnabled() );
-
- _progressBarEngine->setEnabled( animationsEnabled && StyleConfigData::progressBarAnimationsEnabled() );
- _progressBarEngine->setBusyIndicatorEnabled( StyleConfigData::progressBarAnimated() );
-
- // menubar engine
- int menuBarAnimationType( StyleConfigData::menuBarAnimationType() );
- if( menuBarAnimationType == StyleConfigData::MB_FADE && !qobject_cast<MenuBarEngineV1*>( _menuBarEngine ) )
- {
- if( _menuBarEngine )
- {
-
- MenuBarEngineV1* newEngine = new MenuBarEngineV1( this, _menuBarEngine );
- registerEngine( newEngine );
- _menuBarEngine->deleteLater();
- _menuBarEngine = newEngine;
-
- } else registerEngine( _menuBarEngine = new MenuBarEngineV1( this ) );
-
- } else if( menuBarAnimationType == StyleConfigData::MB_FOLLOW_MOUSE && !qobject_cast<MenuBarEngineV2*>( _menuBarEngine ) ) {
-
- if( _menuBarEngine )
- {
-
- MenuBarEngineV2* newEngine = new MenuBarEngineV2( this, _menuBarEngine );
- registerEngine( newEngine );
- _menuBarEngine->deleteLater();
- _menuBarEngine = newEngine;
-
- } else registerEngine( _menuBarEngine = new MenuBarEngineV1( this ) );
-
- }
-
- // menu engine
- int menuAnimationType( StyleConfigData::menuAnimationType() );
- if( menuAnimationType == StyleConfigData::ME_FADE && !qobject_cast<MenuEngineV1*>( _menuEngine ) )
- {
-
- if( _menuEngine )
- {
-
- MenuEngineV1* newEngine = new MenuEngineV1( this, _menuEngine );
- registerEngine( newEngine );
- _menuEngine->deleteLater();
- _menuEngine = newEngine;
-
- } else registerEngine( _menuEngine = new MenuEngineV1( this ) );
-
- } else if( menuAnimationType == StyleConfigData::ME_FOLLOW_MOUSE && !qobject_cast<MenuEngineV2*>( _menuEngine ) ) {
-
- if( _menuEngine )
- {
-
- MenuEngineV2* newEngine = new MenuEngineV2( this, _menuEngine );
- registerEngine( newEngine );
- _menuEngine->deleteLater();
- _menuEngine = newEngine;
-
- } else registerEngine( _menuEngine = new MenuEngineV1( this ) );
-
- }
-
- _menuBarEngine->setEnabled( animationsEnabled && menuBarAnimationType != StyleConfigData::MB_NONE );
- _menuEngine->setEnabled( animationsEnabled && menuAnimationType != StyleConfigData::ME_NONE );
-
- // toolbar engine
- int toolBarAnimationType( StyleConfigData::toolBarAnimationType() );
- if( toolBarAnimationType == StyleConfigData::TB_NONE || toolBarAnimationType == StyleConfigData::TB_FOLLOW_MOUSE )
- {
-
- // disable toolbar engine
- _toolBarEngine->setEnabled( animationsEnabled && toolBarAnimationType == StyleConfigData::TB_FOLLOW_MOUSE );
-
- // unregister all toolbuttons that belong to a toolbar
- foreach( QWidget* widget, _widgetStateEngine->registeredWidgets( AnimationHover|AnimationFocus ) )
- {
- if( qobject_cast<QToolButton*>( widget ) && qobject_cast<QToolBar*>( widget->parentWidget() ) )
- { _widgetStateEngine->unregisterWidget( widget ); }
- }
-
- } else if( toolBarAnimationType == StyleConfigData::TB_FADE ) {
-
- // disable toolbar engine
- _toolBarEngine->setEnabled( false );
-
- // retrieve all registered toolbars
- BaseEngine::WidgetList widgets( _toolBarEngine->registeredWidgets() );
- foreach( QWidget* widget, widgets )
- {
- // get all toolbuttons
- foreach( QObject* child, widget->children() )
- {
- if( QToolButton* toolButton = qobject_cast<QToolButton*>( child ) )
- { _widgetStateEngine->registerWidget( toolButton, AnimationHover ); }
- }
- }
-
- }
-
- }
-
-
- {
-
- // durations
- _widgetEnabilityEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
- _widgetStateEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
- _comboBoxEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
- _toolButtonEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
- _toolBoxEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
- _lineEditEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
- _splitterEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
- _scrollBarEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
- _sliderEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
- _spinBoxEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
- _tabBarEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
- _dockSeparatorEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
- _headerViewEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
- _mdiWindowEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
-
- _progressBarEngine->setDuration( StyleConfigData::progressBarAnimationsDuration() );
- _progressBarEngine->setBusyStepDuration( StyleConfigData::progressBarBusyStepDuration() );
-
- _toolBarEngine->setDuration( StyleConfigData::genericAnimationsDuration() );
- _toolBarEngine->setFollowMouseDuration( StyleConfigData::toolBarAnimationsDuration() );
-
- _menuBarEngine->setDuration( StyleConfigData::menuBarAnimationsDuration() );
- _menuBarEngine->setFollowMouseDuration( StyleConfigData::menuBarFollowMouseAnimationsDuration() );
-
- _menuEngine->setDuration( StyleConfigData::menuAnimationsDuration() );
- _menuEngine->setFollowMouseDuration( StyleConfigData::menuFollowMouseAnimationsDuration() );
-
- }
-
- }
-
- //____________________________________________________________
- void Animations::registerWidget( QWidget* widget ) const
- {
-
- if( !widget ) return;
-
- // check against noAnimations propery
- QVariant propertyValue( widget->property( PropertyNames::noAnimations ) );
- if( propertyValue.isValid() && propertyValue.toBool() ) return;
-
- // these are needed to not register animations for kwin widgets
- if( widget->objectName() == "decoration widget" ) return;
- if( widget->inherits( "KCommonDecorationButton" ) ) return;
- if( widget->inherits( "QShapedPixmapWidget" ) ) return;
-
- // all widgets are registered to the enability engine.
- widgetEnabilityEngine().registerWidget( widget, AnimationEnable );
-
- // install animation timers
- // for optimization, one should put with most used widgets here first
- if( qobject_cast<QToolButton*>(widget) )
- {
-
- toolButtonEngine().registerWidget( widget, AnimationHover );
- bool isInToolBar( qobject_cast<QToolBar*>(widget->parent()) );
- if( isInToolBar )
- {
-
- if( StyleConfigData::toolBarAnimationType() == StyleConfigData::TB_FADE )
- { widgetStateEngine().registerWidget( widget, AnimationHover ); }
-
- } else widgetStateEngine().registerWidget( widget, AnimationHover|AnimationFocus );
-
- } else if( qobject_cast<QAbstractButton*>(widget) ) {
-
- if( qobject_cast<QToolBox*>( widget->parent() ) )
- { toolBoxEngine().registerWidget( widget ); }
-
- widgetStateEngine().registerWidget( widget, AnimationHover|AnimationFocus );
-
- } else if( qobject_cast<QDial*>(widget) ) {
-
- widgetStateEngine().registerWidget( widget, AnimationHover|AnimationFocus );
-
- }
-
- // groupboxes
- else if( QGroupBox* groupBox = qobject_cast<QGroupBox*>( widget ) )
- {
- if( groupBox->isCheckable() )
- { widgetStateEngine().registerWidget( widget, AnimationHover|AnimationFocus ); }
- }
-
- // scrollbar
- else if( qobject_cast<QScrollBar*>( widget ) ) { scrollBarEngine().registerWidget( widget ); }
- else if( qobject_cast<QSlider*>( widget ) ) { sliderEngine().registerWidget( widget ); }
- else if( qobject_cast<QProgressBar*>( widget ) ) { progressBarEngine().registerWidget( widget ); }
- else if( qobject_cast<QSplitterHandle*>( widget ) ) { splitterEngine().registerWidget( widget ); }
- else if( qobject_cast<QMainWindow*>( widget ) ) { dockSeparatorEngine().registerWidget( widget ); }
- else if( qobject_cast<QHeaderView*>( widget ) ) { headerViewEngine().registerWidget( widget ); }
- // menu
- else if( qobject_cast<QMenu*>( widget ) ) { menuEngine().registerWidget( widget ); }
- else if( qobject_cast<QMenuBar*>( widget ) ) { menuBarEngine().registerWidget( widget ); }
- else if( qobject_cast<QTabBar*>( widget ) ) { tabBarEngine().registerWidget( widget ); }
- else if( qobject_cast<QToolBar*>( widget ) ) { toolBarEngine().registerWidget( widget ); }
-
- // editors
- else if( qobject_cast<QComboBox*>( widget ) ) {
- comboBoxEngine().registerWidget( widget, AnimationHover );
- lineEditEngine().registerWidget( widget, AnimationHover|AnimationFocus );
- } else if( qobject_cast<QSpinBox*>( widget ) ) {
- spinBoxEngine().registerWidget( widget );
- lineEditEngine().registerWidget( widget, AnimationHover|AnimationFocus );
- }
- else if( qobject_cast<QLineEdit*>( widget ) ) { lineEditEngine().registerWidget( widget, AnimationHover|AnimationFocus ); }
- else if( qobject_cast<QTextEdit*>( widget ) ) { lineEditEngine().registerWidget( widget, AnimationHover|AnimationFocus ); }
-
- // lists
- else if( qobject_cast<QAbstractItemView*>( widget ) || widget->inherits("Q3ListView") )
- { lineEditEngine().registerWidget( widget, AnimationHover|AnimationFocus ); }
-
- // scrollarea
- else if( QAbstractScrollArea* scrollArea = qobject_cast<QAbstractScrollArea*>( widget ) ) {
-
- if( scrollArea->frameShadow() == QFrame::Sunken && (widget->focusPolicy()&Qt::StrongFocus) )
- { lineEditEngine().registerWidget( widget, AnimationHover|AnimationFocus ); }
-
- }
- // mdi subwindows
- else if( qobject_cast<QMdiSubWindow*>( widget ) )
- { mdiWindowEngine().registerWidget( widget ); }
-
- return;
-
- }
-
- //____________________________________________________________
- void Animations::unregisterWidget( QWidget* widget ) const
- {
-
- if( !widget ) return;
-
- /*
- these are the engines that have not been stored
- inside the list, because they can be register widgets in combination
- with other engines
- */
- widgetEnabilityEngine().unregisterWidget( widget );
- spinBoxEngine().unregisterWidget( widget );
- comboBoxEngine().unregisterWidget( widget );
- toolButtonEngine().unregisterWidget( widget );
- toolBoxEngine().unregisterWidget( widget );
-
- // the following allows some optimization of widget unregistration
- // it assumes that a widget can be registered atmost in one of the
- // engines stored in the list.
- foreach( const BaseEngine::Pointer& engine, _engines )
- { if( engine && engine.data()->unregisterWidget( widget ) ) break; }
-
- }
-
- //_______________________________________________________________
- void Animations::unregisterEngine( QObject* object )
- {
- int index( _engines.indexOf( qobject_cast<BaseEngine*>(object) ) );
- if( index >= 0 ) _engines.removeAt( index );
- }
-
- //_______________________________________________________________
- void Animations::registerEngine( BaseEngine* engine )
- {
- _engines.push_back( engine );
- connect( engine, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterEngine(QObject*)) );
- }
-
-}
+++ /dev/null
-#ifndef oxygenanimations_h
-#define oxygenanimations_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenanimations.h
-// container for all animation engines
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygendockseparatorengine.h"
-#include "oxygenheaderviewengine.h"
-#include "oxygenmdiwindowengine.h"
-#include "oxygenmenubarengine.h"
-#include "oxygenmenuengine.h"
-#include "oxygenprogressbarengine.h"
-#include "oxygenscrollbarengine.h"
-#include "oxygensliderengine.h"
-#include "oxygenspinboxengine.h"
-#include "oxygensplitterengine.h"
-#include "oxygentabbarengine.h"
-#include "oxygentoolbarengine.h"
-#include "oxygentoolboxengine.h"
-#include "oxygenwidgetstateengine.h"
-
-#include <QtCore/QObject>
-#include <QtCore/QList>
-
-namespace Oxygen
-{
-
- //! stores engines
- class Animations: public QObject
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit Animations( QObject* );
-
- //! destructor
- virtual ~Animations( void )
- {}
-
- //! register animations corresponding to given widget, depending on its type.
- void registerWidget( QWidget* widget ) const;
-
- /*! unregister all animations associated to a widget */
- void unregisterWidget( QWidget* widget ) const;
-
- //! enability engine
- WidgetStateEngine& widgetEnabilityEngine( void ) const
- { return *_widgetEnabilityEngine; }
-
- //! abstractButton engine
- WidgetStateEngine& widgetStateEngine( void ) const
- { return *_widgetStateEngine; }
-
- //! editable combobox arrow hover engine
- WidgetStateEngine& comboBoxEngine( void ) const
- { return *_comboBoxEngine; }
-
- //! Tool buttons arrow hover engine
- WidgetStateEngine& toolButtonEngine( void ) const
- { return *_toolButtonEngine; }
-
- //! lineEdit engine
- WidgetStateEngine& lineEditEngine( void ) const
- { return *_lineEditEngine; }
-
- //! splitter engine
- SplitterEngine& splitterEngine( void ) const
- { return *_splitterEngine; }
-
- //! dock separators engine
- DockSeparatorEngine& dockSeparatorEngine( void ) const
- { return *_dockSeparatorEngine; }
-
- //! header view engine
- HeaderViewEngine& headerViewEngine( void ) const
- { return *_headerViewEngine; }
-
- //! progressbar engine
- ProgressBarEngine& progressBarEngine( void ) const
- { return *_progressBarEngine; }
-
- //! menubar engine
- MenuBarBaseEngine& menuBarEngine( void ) const
- { return *_menuBarEngine; }
-
- //! menu engine
- MenuBaseEngine& menuEngine( void ) const
- { return *_menuEngine; }
-
- //! scrollbar engine
- ScrollBarEngine& scrollBarEngine( void ) const
- { return *_scrollBarEngine; }
-
- //! slider engine
- SliderEngine& sliderEngine( void ) const
- { return *_sliderEngine; }
-
- //! spinbox engine
- SpinBoxEngine& spinBoxEngine( void ) const
- { return *_spinBoxEngine; }
-
- //! tabbar
- TabBarEngine& tabBarEngine( void ) const
- { return *_tabBarEngine; }
-
- //! toolbar
- ToolBarEngine& toolBarEngine( void ) const
- { return *_toolBarEngine; }
-
- //! toolbox
- ToolBoxEngine& toolBoxEngine( void ) const
- { return *_toolBoxEngine; }
-
- //! mdi windows
- MdiWindowEngine& mdiWindowEngine( void ) const
- { return *_mdiWindowEngine; }
-
- //! setup engines
- void setupEngines( void );
-
- protected slots:
-
- //! enregister engine
- void unregisterEngine( QObject* );
- private:
-
- //! register new engine
- void registerEngine( BaseEngine* engine );
-
- //! dock separator handle hover effect
- DockSeparatorEngine* _dockSeparatorEngine;
-
- //! headerview hover effect
- HeaderViewEngine* _headerViewEngine;
-
- //! widget enability engine
- WidgetStateEngine* _widgetEnabilityEngine;
-
- //! abstract button engine
- WidgetStateEngine* _widgetStateEngine;
-
- //! editable combobox arrow hover effect
- WidgetStateEngine* _comboBoxEngine;
-
- //! mennu toolbutton arrow hover effect
- WidgetStateEngine* _toolButtonEngine;
-
- //! line editor engine
- WidgetStateEngine* _lineEditEngine;
-
- //! QSplitter engine
- SplitterEngine* _splitterEngine;
-
- //! progressbar engine
- ProgressBarEngine* _progressBarEngine;
-
- //! menubar engine
- MenuBarBaseEngine* _menuBarEngine;
-
- //! menu engine
- MenuBaseEngine* _menuEngine;
-
- //! scrollbar engine
- ScrollBarEngine* _scrollBarEngine;
-
- //! slider engine
- SliderEngine* _sliderEngine;
-
- //! spinbox engine
- SpinBoxEngine* _spinBoxEngine;
-
- //! tabbar engine
- TabBarEngine* _tabBarEngine;
-
- //! toolbar engine
- ToolBarEngine* _toolBarEngine;
-
- //! toolbar engine
- ToolBoxEngine* _toolBoxEngine;
-
- //! mdi window
- MdiWindowEngine* _mdiWindowEngine;
-
- //! keep list of existing engines
- QList< BaseEngine::Pointer > _engines;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenbaseengine.cpp
-// base engine
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygenbaseengine.moc"
+++ /dev/null
-#ifndef oxygenbaseengine_h
-#define oxygenbaseengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenbaseengine.h
-// base engine
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include <QtCore/QObject>
-#include <QtCore/QSet>
-#include <QtCore/QWeakPointer>
-
-namespace Oxygen
-{
-
- //! base class for all animation engines
- /*! it is used to store configuration values used by all animations stored in the engine */
- class BaseEngine: public QObject
- {
-
- Q_OBJECT
-
- public:
-
- typedef QWeakPointer<BaseEngine> Pointer;
-
- //! constructor
- explicit BaseEngine( QObject* parent ):
- QObject( parent ),
- _enabled( true ),
- _duration( 200 )
- {}
-
- //! destructor
- virtual ~BaseEngine( void )
- {}
-
- //! enability
- virtual void setEnabled( bool value )
- { _enabled = value; }
-
- //! enability
- virtual bool enabled( void ) const
- { return _enabled; }
-
- //! duration
- virtual void setDuration( int value )
- { _duration = value; }
-
- //! duration
- virtual int duration( void ) const
- { return _duration; }
-
- //! unregister widget
- virtual bool unregisterWidget( QObject* object ) = 0;
-
- //! list of widgets
- typedef QSet<QWidget*> WidgetList;
-
- //! returns registered widgets
- virtual WidgetList registeredWidgets( void ) const
- { return WidgetList(); }
-
- private:
-
- //! engine enability
- bool _enabled;
-
- //! animation duration
- int _duration;
-
- };
-
-}
-
-#endif
+++ /dev/null
-#ifndef oxygendatamap_h
-#define oxygendatamap_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygendatamap.h
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include <QtCore/QObject>
-#include <QtCore/QMap>
-#include <QtCore/QWeakPointer>
-
-#include <QtGui/QPaintDevice>
-
-namespace Oxygen
-{
-
- //! data map
- /*! it maps templatized data object to associated object */
- template< typename K, typename T > class BaseDataMap: public QMap< const K*, QWeakPointer<T> >
- {
-
- public:
-
- typedef const K* Key;
- typedef QWeakPointer<T> Value;
-
- //! constructor
- BaseDataMap( void ):
- QMap<Key, Value>(),
- _enabled( true ),
- _lastKey( NULL )
- {}
-
- //! destructor
- virtual ~BaseDataMap( void )
- {}
-
- //! insertion
- virtual typename QMap< Key, Value >::iterator insert( const Key& key, const Value& value, bool enabled = true )
- {
- if( value ) value.data()->setEnabled( enabled );
- return QMap< Key, Value >::insert( key, value );
- }
-
- //! find value
- Value find( Key key )
- {
- if( !( enabled() && key ) ) return Value();
- if( key == _lastKey ) return _lastValue;
- else {
- Value out;
- typename QMap<Key, Value>::iterator iter( QMap<Key, Value>::find( key ) );
- if( iter != QMap<Key, Value>::end() ) out = iter.value();
- _lastKey = key;
- _lastValue = out;
- return out;
- }
- }
-
- //! unregister widget
- bool unregisterWidget( Key key )
- {
-
- // check key
- if( !key ) return false;
-
- // clear last value if needed
- if( key == _lastKey )
- {
-
- if( _lastValue ) _lastValue.clear();
- _lastKey = NULL;
-
- }
-
- // find key in map
- typename QMap<Key, Value>::iterator iter( QMap<Key, Value>::find( key ) );
- if( iter == QMap<Key, Value>::end() ) return false;
-
- // delete value from map if found
- if( iter.value() ) iter.value().data()->deleteLater();
- QMap<Key, Value>::erase( iter );
-
- return true;
-
- }
-
- //! maxFrame
- void setEnabled( bool enabled )
- {
- _enabled = enabled;
- foreach( const Value& value, *this )
- { if( value ) value.data()->setEnabled( enabled ); }
- }
-
- //! enability
- bool enabled( void ) const
- { return _enabled; }
-
- //! duration
- void setDuration( int duration ) const
- {
- foreach( const Value& value, *this )
- { if( value ) value.data()->setDuration( duration ); }
- }
-
- private:
-
- //! enability
- bool _enabled;
-
- //! last key
- Key _lastKey;
-
- //! last value
- Value _lastValue;
-
- };
-
- //! standard data map, using QObject as a key
- template< typename T > class DataMap: public BaseDataMap< QObject, T >
- {
-
- public:
-
- //! constructor
- DataMap( void )
- {}
-
- //! destructor
- virtual ~DataMap( void )
- {}
-
- };
-
- //! QPaintDevice based dataMap
- template< typename T > class PaintDeviceDataMap: public BaseDataMap< QPaintDevice, T >
- {
-
- public:
-
- //! constructor
- PaintDeviceDataMap( void )
- {}
-
- //! destructor
- virtual ~PaintDeviceDataMap( void )
- {}
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygendockseparatordata.cpp
-// generic data container for widgetstate hover (mouse-over) animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygendockseparatordata.h"
-#include "oxygendockseparatordata.moc"
-
-#include <QtCore/QTextStream>
-namespace Oxygen
-{
-
- //______________________________________________
- DockSeparatorData::DockSeparatorData( QObject* parent, QWidget* target, int duration ):
- AnimationData( parent, target )
- {
-
- // setup animation
- _horizontalData._animation = new Animation( duration, this );
- _horizontalData._animation.data()->setStartValue( 0.0 );
- _horizontalData._animation.data()->setEndValue( 1.0 );
- _horizontalData._animation.data()->setTargetObject( this );
- _horizontalData._animation.data()->setPropertyName( "horizontalOpacity" );
-
- // setup animation
- _verticalData._animation = new Animation( duration, this );
- _verticalData._animation.data()->setStartValue( 0.0 );
- _verticalData._animation.data()->setEndValue( 1.0 );
- _verticalData._animation.data()->setTargetObject( this );
- _verticalData._animation.data()->setPropertyName( "verticalOpacity" );
-
- }
-
- //______________________________________________
- void DockSeparatorData::updateRect( const QRect& r, const Qt::Orientation& orientation, bool hovered )
- {
-
- Data& data( orientation == Qt::Vertical ? _verticalData:_horizontalData );
-
- if( hovered )
- {
- data._rect = r;
- if( data._animation.data()->direction() == Animation::Backward )
- {
- if( data._animation.data()->isRunning() ) data._animation.data()->stop();
- data._animation.data()->setDirection( Animation::Forward );
- data._animation.data()->start();
- }
-
- } else if( data._animation.data()->direction() == Animation::Forward && r == data._rect ) {
-
- if( data._animation.data()->isRunning() ) data._animation.data()->stop();
- data._animation.data()->setDirection( Animation::Backward );
- data._animation.data()->start();
-
- }
-
- }
-
-}
+++ /dev/null
-#ifndef oxygendockseparator_datah
-#define oxygendockseparator_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygendockseparatordata.h
-// generic data container for widgetstate hover (mouse-over) animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygengenericdata.h"
-#include "oxygenanimation.h"
-
-namespace Oxygen
-{
-
- //! dock widget splitters hover effect
- class DockSeparatorData: public AnimationData
- {
-
- Q_OBJECT
-
- //! declare opacity property
- Q_PROPERTY( qreal verticalOpacity READ verticalOpacity WRITE setVerticalOpacity )
- Q_PROPERTY( qreal horizontalOpacity READ horizontalOpacity WRITE setHorizontalOpacity )
-
- public:
-
- //! constructor
- DockSeparatorData( QObject* parent, QWidget* target, int duration );
-
- //! destructor
- virtual ~DockSeparatorData( void )
- {}
-
- //@}
-
- /*!
- returns true if hover has Changed
- and starts timer accordingly
- */
- virtual void updateRect( const QRect&, const Qt::Orientation&, bool hovered );
-
- //! returns true if current splitter is animated
- virtual bool isAnimated( QRect r, const Qt::Orientation& orientation ) const
- { return orientation == Qt::Vertical ? _verticalData.isAnimated( r ):_horizontalData.isAnimated( r ); }
-
- //! opacity for given orientation
- qreal opacity( const Qt::Orientation& orientation ) const
- { return orientation == Qt::Vertical ? verticalOpacity():horizontalOpacity(); }
-
- //! duration
- virtual void setDuration( int duration )
- {
- horizontalAnimation().data()->setDuration( duration );
- verticalAnimation().data()->setDuration( duration );
- }
-
- //!@name horizontal splitter data
- //@{
-
- Animation::Pointer horizontalAnimation( void ) const
- { return _horizontalData._animation; }
-
- const QRect& horizontalRect( void ) const
- { return _horizontalData._rect; }
-
- void setHorizontalRect( const QRect& r )
- { _horizontalData._rect = r; }
-
- qreal horizontalOpacity( void ) const
- { return _horizontalData._opacity; }
-
- void setHorizontalOpacity( qreal value )
- {
-
- value = digitize( value );
- if( _horizontalData._opacity == value ) return;
- _horizontalData._opacity = value;
- if( target() && !horizontalRect().isEmpty() ) target().data()->update( horizontalRect() );
-
- }
-
- //@}
-
-
- //!@name vertical splitter data
- //@{
-
- Animation::Pointer verticalAnimation( void ) const
- { return _verticalData._animation; }
-
- const QRect& verticalRect( void ) const
- { return _verticalData._rect; }
-
- void setVerticalRect( const QRect& r )
- { _verticalData._rect = r; }
-
- qreal verticalOpacity( void ) const
- { return _verticalData._opacity; }
-
- void setVerticalOpacity( qreal value )
- {
- value = digitize( value );
- if( _verticalData._opacity == value ) return;
- _verticalData._opacity = value;
- if( target() && !verticalRect().isEmpty() ) target().data()->update( verticalRect() );
- }
-
- //@}
-
-
- private:
-
- //! stores data needed for animation
- class Data
- {
-
- public:
-
- //! constructor
- Data( void ):
- _opacity( AnimationData::OpacityInvalid )
- {}
-
- //! true if is animated
- bool isAnimated( QRect r ) const
- { return r == _rect && _animation.data()->isRunning(); }
-
- //! animation pointer
- Animation::Pointer _animation;
-
- //! opacity variable
- qreal _opacity;
-
- //! stores active separator rect
- QRect _rect;
-
- };
-
- //! horizontal
- Data _horizontalData;
-
- //! vertical
- Data _verticalData;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygendockseparatorengine.cpp
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygendockseparatorengine.h"
-#include "oxygendockseparatorengine.moc"
-
-#include <QtCore/QEvent>
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- bool DockSeparatorEngine::registerWidget( QWidget* widget )
- {
-
- if( !widget ) return false;
-
- // create new data class
- if( !_data.contains( widget ) ) _data.insert( widget, new DockSeparatorData( this, widget, duration() ), enabled() );
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
- return true;
-
- }
-
-}
+++ /dev/null
-#ifndef oxygendockseparatorengine_h
-#define oxygendockseparatorengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygendockseparatorengine.h
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygendockseparatordata.h"
-
-namespace Oxygen
-{
-
- //! stores dockseparator hovered action and timeLine
- class DockSeparatorEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit DockSeparatorEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~DockSeparatorEngine( void )
- {}
-
- //! register dockseparator
- virtual bool registerWidget( QWidget* );
-
- //! update rect and hover value for data matching widget
- virtual void updateRect( const QObject* object, const QRect& r, const Qt::Orientation orientation, bool hovered )
- {
- if( DataMap<DockSeparatorData>::Value data = _data.find( object ) )
- { data.data()->updateRect( r, orientation, hovered ); }
- }
-
- //! returns true if object is animated
- virtual bool isAnimated( const QObject* object, const QRect& r, const Qt::Orientation orientation )
- {
- if( DataMap<DockSeparatorData>::Value data = _data.find( object ) )
- {
- return data.data()->isAnimated( r, orientation );
- } else return false;
-
- }
-
- //! returns true if object is animated
- virtual qreal opacity( const QObject* object, const Qt::Orientation orientation )
- {
- if( DataMap<DockSeparatorData>::Value data = _data.find( object ) )
- {
- return data.data()->opacity( orientation );
- } else return AnimationData::OpacityInvalid;
- }
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! data map
- DataMap<DockSeparatorData> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenenabledata.cpp
-// generic data container for widget enable/disable animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenenabledata.h"
-#include "oxygenenabledata.moc"
-
-namespace Oxygen
-{
-
- //______________________________________________
- bool EnableData::eventFilter( QObject* object, QEvent* event )
- {
-
- if( !enabled() ) return WidgetStateData::eventFilter( object, event );
-
- // check event type
- switch( event->type() )
- {
-
- // enter event
- case QEvent::EnabledChange:
- {
- if( QWidget* widget = qobject_cast<QWidget*>( object ) )
- { updateState( widget->isEnabled() ); }
- break;
- }
-
- default: break;
-
- }
-
- return WidgetStateData::eventFilter( object, event );
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenenable_datah
-#define oxygenenable_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenenabledata.h
-// generic data container for widget enable/disable animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenwidgetstatedata.h"
-
-namespace Oxygen
-{
-
- //! Enable data
- class EnableData: public WidgetStateData
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- EnableData( QObject* parent, QWidget* target, int duration, bool state = true ):
- WidgetStateData( parent, target, duration, state )
- { target->installEventFilter( this ); }
-
- //! destructor
- virtual ~EnableData( void )
- {}
-
- //! event filter
- virtual bool eventFilter( QObject*, QEvent* );
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygengenericdata.cpp
-// generic data container for widget animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygengenericdata.h"
-#include "oxygengenericdata.moc"
-
-#include <QTextStream>
-
-namespace Oxygen
-{
-
- //______________________________________________
- GenericData::GenericData( QObject* parent, QWidget* target, int duration ):
- AnimationData( parent, target ),
- _animation( new Animation( duration, this ) ),
- _opacity(0)
- { setupAnimation( _animation, "opacity" ); }
-
-}
+++ /dev/null
-#ifndef oxygengeneric_datah
-#define oxygengeneric_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygengenericdata.h
-// generic data container for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimationdata.h"
-#include "oxygenanimation.h"
-
-#include <QtCore/QObject>
-#include <QtCore/QTextStream>
-namespace Oxygen
-{
-
-
- //! generic data
- class GenericData: public AnimationData
- {
-
- Q_OBJECT
-
- //! declare opacity property
- Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity )
-
- public:
-
- //! constructor
- GenericData( QObject* parent, QWidget* widget, int duration );
-
- //! destructor
- virtual ~GenericData( void )
- {}
-
- //! return animation object
- virtual const Animation::Pointer& animation() const
- { return _animation; }
-
- //! duration
- virtual void setDuration( int duration )
- { _animation.data()->setDuration( duration ); }
-
- //! opacity
- virtual qreal opacity( void ) const
- { return _opacity; }
-
- //! opacity
- virtual void setOpacity( qreal value )
- {
-
- value = digitize( value );
- if( _opacity == value ) return;
-
- _opacity = value;
- setDirty();
-
- }
-
- private:
-
- //! animation handling
- Animation::Pointer _animation;
-
- //! opacity variable
- qreal _opacity;
-
- };
-
-}
-
-#endif
+++ /dev/null
-// krazy:excludeall=qclasses
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenheaderviewdata.cpp
-// data container for QHeaderView animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenheaderviewdata.h"
-#include "oxygenheaderviewdata.moc"
-
-#include <QtGui/QHoverEvent>
-
-namespace Oxygen
-{
-
- //______________________________________________
- HeaderViewData::HeaderViewData( QObject* parent, QWidget* target, int duration ):
- AnimationData( parent, target )
- {
-
- target->installEventFilter( this );
-
- _current._animation = new Animation( duration, this );
- setupAnimation( currentIndexAnimation(), "currentOpacity" );
- currentIndexAnimation().data()->setDirection( Animation::Forward );
-
- _previous._animation = new Animation( duration, this );
- setupAnimation( previousIndexAnimation(), "previousOpacity" );
- previousIndexAnimation().data()->setDirection( Animation::Backward );
-
- }
-
- //______________________________________________
- bool HeaderViewData::updateState( const QPoint& position , bool hovered )
- {
-
- if( !enabled() ) return false;
-
- const QHeaderView* local( qobject_cast<const QHeaderView*>( target().data() ) );
- if( !local ) return false;
-
- int index( local->logicalIndexAt( position ) );
- if( index < 0 ) return false;
-
- if( hovered )
- {
-
-
- if( index != currentIndex() )
- {
-
- if( currentIndex() >= 0 )
- {
- setPreviousIndex( currentIndex() );
- setCurrentIndex( -1 );
- previousIndexAnimation().data()->restart();
- }
-
- setCurrentIndex( index );
-
- /*
- for now animation is only triggered when hovering the sorting section,
- since no hover effect is implemented for all other sections
- */
- if( index == local->sortIndicatorSection() )
- { currentIndexAnimation().data()->restart(); }
-
- return true;
-
- } else return false;
-
- } else if( index == currentIndex() ) {
-
- setPreviousIndex( currentIndex() );
- setCurrentIndex( -1 );
- previousIndexAnimation().data()->restart();
- return true;
-
- } else return false;
-
- }
-
- //______________________________________________
- Animation::Pointer HeaderViewData::animation( const QPoint& position ) const
- {
-
- if( !enabled() ) return Animation::Pointer();
-
- const QHeaderView* local( qobject_cast<const QHeaderView*>( target().data() ) );
- if( !local ) return Animation::Pointer();
-
- int index( local->logicalIndexAt( position ) );
- if( index < 0 ) return Animation::Pointer();
- else if( index == currentIndex() ) return currentIndexAnimation();
- else if( index == previousIndex() ) return previousIndexAnimation();
- else return Animation::Pointer();
-
- }
-
- //______________________________________________
- qreal HeaderViewData::opacity( const QPoint& position ) const
- {
-
- if( !enabled() ) return OpacityInvalid;
-
- const QHeaderView* local( qobject_cast<const QHeaderView*>( target().data() ) );
- if( !local ) return OpacityInvalid;
-
- int index( local->logicalIndexAt( position ) );
- if( index < 0 ) return OpacityInvalid;
- else if( index == currentIndex() ) return currentOpacity();
- else if( index == previousIndex() ) return previousOpacity();
- else return OpacityInvalid;
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenheaderview_datah
-#define oxygenheaderview_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenheaderviewdata.h
-// data container for QHeaderView animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimationdata.h"
-#include <QtGui/QHeaderView>
-
-namespace Oxygen
-{
-
- //! headerviews
- class HeaderViewData: public AnimationData
- {
-
- Q_OBJECT
-
- //! declare opacity property
- Q_PROPERTY( qreal currentOpacity READ currentOpacity WRITE setCurrentOpacity )
- Q_PROPERTY( qreal previousOpacity READ previousOpacity WRITE setPreviousOpacity )
-
- public:
-
- //! constructor
- HeaderViewData( QObject* parent, QWidget* target, int duration );
-
- //! destructor
- virtual ~HeaderViewData( void )
- {}
-
- //! duration
- void setDuration( int duration )
- {
- currentIndexAnimation().data()->setDuration( duration );
- previousIndexAnimation().data()->setDuration( duration );
- }
-
- //! update state
- bool updateState( const QPoint&, bool );
-
- //!@name current index handling
- //@{
-
- //! current opacity
- virtual qreal currentOpacity( void ) const
- { return _current._opacity; }
-
- //! current opacity
- virtual void setCurrentOpacity( qreal value )
- {
- value = digitize( value );
- if( _current._opacity == value ) return;
- _current._opacity = value;
- setDirty();
- }
-
- //! current index
- virtual int currentIndex( void ) const
- { return _current._index; }
-
- //! current index
- virtual void setCurrentIndex( int index )
- { _current._index = index; }
-
- //! current index animation
- virtual const Animation::Pointer& currentIndexAnimation( void ) const
- { return _current._animation; }
-
- //@}
-
- //!@name previous index handling
- //@{
-
- //! previous opacity
- virtual qreal previousOpacity( void ) const
- { return _previous._opacity; }
-
- //! previous opacity
- virtual void setPreviousOpacity( qreal value )
- {
- value = digitize( value );
- if( _previous._opacity == value ) return;
- _previous._opacity = value;
- setDirty();
- }
-
- //! previous index
- virtual int previousIndex( void ) const
- { return _previous._index; }
-
- //! previous index
- virtual void setPreviousIndex( int index )
- { _previous._index = index; }
-
- //! previous index Animation
- virtual const Animation::Pointer& previousIndexAnimation( void ) const
- { return _previous._animation; }
-
- //@}
-
- //! return Animation associated to action at given position, if any
- virtual Animation::Pointer animation( const QPoint& position ) const;
-
- //! return opacity associated to action at given position, if any
- virtual qreal opacity( const QPoint& position ) const;
-
- protected:
-
- //! dirty
- inline virtual void setDirty( void ) const;
-
- private:
-
- //! container for needed animation data
- class Data
- {
- public:
-
- //! default constructor
- Data( void ):
- _opacity(0),
- _index(-1)
- {}
-
- Animation::Pointer _animation;
- qreal _opacity;
- int _index;
- };
-
- //! current tab animation data (for hover enter animations)
- Data _current;
-
- //! previous tab animations data (for hover leave animations)
- Data _previous;
-
- };
-
-
- //__________________________________________________________
- void HeaderViewData::setDirty( void ) const
- {
- if( QHeaderView* header = qobject_cast<QHeaderView*>( target().data() ) )
- {
- const int firstIndex( qMin( previousIndex(), currentIndex() ) );
- const int lastIndex( qMax( previousIndex(), currentIndex() ) );
- if( firstIndex >= 0 ) header->headerDataChanged( header->orientation(), firstIndex, lastIndex );
- else if( lastIndex >= 0 ) header->headerDataChanged( header->orientation(), lastIndex, lastIndex );
- }
- }
-
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenheaderviewengine.cpp
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenheaderviewengine.h"
-#include "oxygenheaderviewengine.moc"
-
-#include <QtCore/QEvent>
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- bool HeaderViewEngine::registerWidget( QWidget* widget )
- {
-
- if( !widget ) return false;
-
- // create new data class
- if( !_data.contains( widget ) ) _data.insert( widget, new HeaderViewData( this, widget, duration() ), enabled() );
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
- return true;
-
- }
-
- //____________________________________________________________
- bool HeaderViewEngine::updateState( const QObject* object, const QPoint& position, bool value )
- {
- DataMap<HeaderViewData>::Value data( _data.find( object ) );
- return ( data && data.data()->updateState( position, value ) );
- }
-
-}
+++ /dev/null
-#ifndef oxygenheaderviewengine_h
-#define oxygenheaderviewengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenheaderviewengine.h
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygenheaderviewdata.h"
-
-namespace Oxygen
-{
-
- //! stores headerview hovered action and timeLine
- class HeaderViewEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit HeaderViewEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~HeaderViewEngine( void )
- {}
-
- //! register headerview
- virtual bool registerWidget( QWidget* );
-
- //! true if widget hover state is changed
- virtual bool updateState( const QObject*, const QPoint&, bool );
-
- //! true if widget is animated
- virtual bool isAnimated( const QObject* object, const QPoint& point )
- {
- if( DataMap<HeaderViewData>::Value data = _data.find( object ) )
- { if( Animation::Pointer animation = data.data()->animation( point ) ) return animation.data()->isRunning(); }
- return false;
- }
-
- //! animation opacity
- virtual qreal opacity( const QObject* object, const QPoint& point )
- { return isAnimated( object, point ) ? _data.find( object ).data()->opacity( point ) : AnimationData::OpacityInvalid; }
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! data map
- DataMap<HeaderViewData> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenmdiwindowdata.cpp
-// mdi window data container for window titlebar buttons
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenmdiwindowdata.h"
-#include "oxygenmdiwindowdata.moc"
-
-namespace Oxygen
-{
-
- //________________________________________________
- MdiWindowData::MdiWindowData( QObject* parent, QWidget* target, int duration ):
- AnimationData( parent, target )
- {
- _currentData._animation = new Animation( duration, this );
- _previousData._animation = new Animation( duration, this );
- setupAnimation( currentAnimation(), "currentOpacity" );
- setupAnimation( previousAnimation(), "previousOpacity" );
-
- currentAnimation().data()->setDirection( Animation::Forward );
- previousAnimation().data()->setDirection( Animation::Backward );
- }
-
- //______________________________________________
- bool MdiWindowData::updateState( int primitive, bool state )
- {
-
- if( state )
- {
-
- if( primitive != _currentData._primitive )
- {
-
- _previousData.updateSubControl( _currentData._primitive );
- _currentData.updateSubControl( primitive );
- return true;
-
- } else return false;
-
- } else {
-
- bool changed( false );
- if( primitive == _currentData._primitive )
- {
- changed |= _currentData.updateSubControl( 0 );
- changed |= _previousData.updateSubControl( primitive );
- }
-
- return changed;
-
- }
-
- }
-
- //______________________________________________
- bool MdiWindowData::Data::updateSubControl( int value )
- {
- if( _primitive == value ) return false;
- else {
-
- _primitive = value;
- if( _animation.data()->isRunning() ) _animation.data()->stop();
- if( _primitive != 0 ) _animation.data()->start();
- return true;
-
- }
- }
-
-}
+++ /dev/null
-#ifndef oxygenmdiwindow_datah
-#define oxygenmdiwindow_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenmdiwindowdata.h
-// mdi window data container for window titlebar buttons
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimationdata.h"
-
-#include <QtGui/QStyle>
-
-namespace Oxygen
-{
-
- //! handles mdiwindow arrows hover
- class MdiWindowData: public AnimationData
- {
-
- Q_OBJECT
-
- //! declare opacity property
- Q_PROPERTY( qreal currentOpacity READ currentOpacity WRITE setCurrentOpacity )
- Q_PROPERTY( qreal previousOpacity READ previousOpacity WRITE setPreviousOpacity )
-
- public:
-
- //! constructor
- MdiWindowData( QObject*, QWidget*, int );
-
- //! destructor
- virtual ~MdiWindowData( void )
- {}
-
- //! animation state
- virtual bool updateState( int primitive, bool value );
-
- //! animation state
- virtual bool isAnimated( int primitive ) const
- {
- return(
- ( primitive == _currentData._primitive && currentAnimation().data()->isRunning() ) ||
- ( primitive == _previousData._primitive && previousAnimation().data()->isRunning() ) );
- }
-
- //! opacity
- virtual qreal opacity( int primitive ) const
- {
- if( primitive == _currentData._primitive ) return currentOpacity();
- else if( primitive == _previousData._primitive ) return previousOpacity();
- else return OpacityInvalid;
- }
-
- //! duration
- virtual void setDuration( int duration )
- {
- currentAnimation().data()->setDuration( duration );
- previousAnimation().data()->setDuration( duration );
- }
-
- //!@name current animation
- //@{
-
- //! opacity
- qreal currentOpacity( void ) const
- { return _currentData._opacity; }
-
- //! opacity
- void setCurrentOpacity( qreal value )
- {
- value = digitize( value );
- if( _currentData._opacity == value ) return;
- _currentData._opacity = value;
- setDirty();
- }
-
- //! animation
- Animation::Pointer currentAnimation( void ) const
- { return _currentData._animation; }
-
- //@}
- //!@name previous animation
- //@{
-
- //! opacity
- qreal previousOpacity( void ) const
- { return _previousData._opacity; }
-
- //! opacity
- void setPreviousOpacity( qreal value )
- {
- value = digitize( value );
- if( _previousData._opacity == value ) return;
- _previousData._opacity = value;
- setDirty();
- }
-
- //! animation
- Animation::Pointer previousAnimation( void ) const
- { return _previousData._animation; }
-
- //@}
-
- private:
-
- //! container for needed animation data
- class Data
- {
-
- public:
-
- //! default constructor
- Data( void ):
- _primitive( 0 ),
- _opacity(0)
- {}
-
- //! subcontrol
- bool updateSubControl( int );
-
- //! subcontrol
- int _primitive;
-
- //! animation
- Animation::Pointer _animation;
-
- //! opacity
- qreal _opacity;
-
- };
-
- //! current data
- Data _currentData;
-
- //! previous data
- Data _previousData;
-
- };
-
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenmdiwindowengine.cpp
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenmdiwindowengine.h"
-#include "oxygenmdiwindowengine.moc"
-
-#include <QtCore/QEvent>
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- bool MdiWindowEngine::registerWidget( QWidget* widget )
- {
-
- if( !widget ) return false;
-
- // create new data class
- if( !_data.contains( widget ) ) _data.insert( widget, new MdiWindowData( this, widget, duration() ), enabled() );
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
- return true;
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenmdiwindowengine_h
-#define oxygenmdiwindowengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenmdiwindowengine.h
-// stores event filters and maps widgets to animations
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygenmdiwindowdata.h"
-
-namespace Oxygen
-{
-
- //! handle mdiwindow arrows hover effect
- class MdiWindowEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit MdiWindowEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~MdiWindowEngine( void )
- {}
-
- //! register widget
- virtual bool registerWidget( QWidget* );
-
- //! state
- virtual bool updateState( const QObject* object, int primitive, bool value )
- {
- if( DataMap<MdiWindowData>::Value data = _data.find( object ) )
- {
- return data.data()->updateState( primitive, value );
- } else return false;
- }
-
- //! true if widget is animated
- virtual bool isAnimated( const QObject* object, int primitive )
- {
- if( DataMap<MdiWindowData>::Value data = _data.find( object ) )
- {
- return data.data()->isAnimated( primitive );
- } else return false;
-
- }
-
- //! animation opacity
- virtual qreal opacity( const QObject* object, int primitive )
- {
- if( DataMap<MdiWindowData>::Value data = _data.find( object ) )
- {
- return data.data()->opacity( primitive );
- } else return AnimationData::OpacityInvalid;
- }
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! data map
- DataMap<MdiWindowData> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenmenubardata.cpp
-// data container for QMenuBar animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenmenubardata.h"
-#include "oxygenmenubardata.moc"
-
-#include <QtCore/QTextStream>
-
-namespace Oxygen
-{
-
- //______________________________________________
- MenuBarData::MenuBarData( QObject* parent, QWidget* target ):
- AnimationData( parent, target ),
- _isMenu( qobject_cast<QMenu*>( target ) ),
- _motions( -1 )
- {}
-
- //______________________________________________
- MenuBarDataV1::MenuBarDataV1( QObject* parent, QWidget* target, int duration ):
- MenuBarData( parent, target )
- {
-
- target->installEventFilter( this );
-
- // setup timeLine
- _current._animation = new Animation( duration, this );
- setupAnimation( currentAnimation(), "currentOpacity" );
- currentAnimation().data()->setDirection( Animation::Forward );
-
- _previous._animation = new Animation( duration, this );
- setupAnimation( previousAnimation(), "previousOpacity" );
- previousAnimation().data()->setDirection( Animation::Backward );
-
- }
-
- //______________________________________________
- bool MenuBarDataV1::eventFilter( QObject* object, QEvent* event )
- {
-
- if( !( enabled() && object == target().data() ) )
- { return AnimationData::eventFilter( object, event ); }
-
- // check event type
- switch( event->type() )
- {
-
- case QEvent::Enter:
- {
- // first need to call proper event processing
- // then implement transition
- object->event( event );
- enterEvent( object );
- if( _isMenu ) _motions = -1;
- break;
- }
-
- case QEvent::Leave:
- {
- // first need to call proper event processing
- // then implement transition
- object->event( event );
- leaveEvent( object );
- break;
- }
-
- case QEvent::MouseMove:
- {
-
- // first need to call proper event processing
- // then implement transition
- if( !_isMenu || _motions++ > 0 ) object->event( event );
- mouseMoveEvent( object );
- break;
-
- }
-
- case QEvent::MouseButtonPress:
- {
- // first need to call proper event processing
- // then implement transition
- mousePressEvent( object );
- break;
- }
-
- default: break;
-
- }
-
- // always forward event
- return AnimationData::eventFilter( object, event );
-
- }
-
- //______________________________________________
- MenuBarDataV2::MenuBarDataV2( QObject* parent, QWidget* target, int duration ):
- MenuBarData( parent, target ),
- _opacity(0),
- _progress(0),
- _entered( true )
- {
-
- target->installEventFilter( this );
-
- _animation = new Animation( duration, this );
- animation().data()->setDirection( Animation::Forward );
- animation().data()->setStartValue( 0.0 );
- animation().data()->setEndValue( 1.0 );
- animation().data()->setTargetObject( this );
- animation().data()->setPropertyName( "opacity" );
-
- _progressAnimation = new Animation( duration, this );
- progressAnimation().data()->setDirection( Animation::Forward );
- progressAnimation().data()->setStartValue( 0 );
- progressAnimation().data()->setEndValue( 1 );
- progressAnimation().data()->setTargetObject( this );
- progressAnimation().data()->setPropertyName( "progress" );
- progressAnimation().data()->setEasingCurve( QEasingCurve::Linear );
-
- }
-
- //______________________________________________
- bool MenuBarDataV2::eventFilter( QObject* object, QEvent* event )
- {
-
- if( !enabled() ) return false;
-
- // check event type
- switch( event->type() )
- {
-
- case QEvent::Enter:
- {
- // first need to call proper event processing
- // then implement transition
- object->event( event );
- enterEvent( object );
- if( !_isMenu ) _motions = -1;
- break;
- }
-
- case QEvent::Hide:
- case QEvent::Leave:
- {
- // first need to call proper event processing
- // then implement transition
- object->event( event );
- if( _timer.isActive() ) _timer.stop();
- _timer.start( 100, this );
- break;
- }
-
- case QEvent::MouseMove:
- {
- // first need to call proper event processing
- // then implement transition
- if( !_isMenu || _motions++ > 0 ) object->event( event );
- mouseMoveEvent( object );
- break;
- }
-
- default: break;
-
- }
-
- // always forward event
- return false;
-
- }
-
- //____________________________________________________________
- void MenuBarDataV2::updateAnimatedRect( void )
- {
-
- // check rect validity
- if( !( currentRect().isValid() && previousRect().isValid() ) )
- {
- _animatedRect = QRect();
- return;
- }
-
- // compute rect located 'between' previous and current
- _animatedRect.setLeft( previousRect().left() + progress()*(currentRect().left() - previousRect().left()) );
- _animatedRect.setRight( previousRect().right() + progress()*(currentRect().right() - previousRect().right()) );
- _animatedRect.setTop( previousRect().top() + progress()*(currentRect().top() - previousRect().top()) );
- _animatedRect.setBottom( previousRect().bottom() + progress()*(currentRect().bottom() - previousRect().bottom()) );
-
- // trigger update
- setDirty();
-
- return;
-
- }
-
- //___________________________________________________________
- void MenuBarDataV2::timerEvent( QTimerEvent *event )
- {
-
- if( event->timerId() != _timer.timerId() ) return AnimationData::timerEvent( event );
- _timer.stop();
- leaveEvent( target().data() );
- }
-
-}
+++ /dev/null
-#ifndef oxygenmenubar_datah
-#define oxygenmenubar_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenmenubardata.h
-// data container for QMenuBar animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimationdata.h"
-#include <QtGui/QMenuBar>
-#include <QtCore/QBasicTimer>
-#include <QtCore/QWeakPointer>
-
-namespace Oxygen
-{
-
- //! widget index
- enum WidgetIndex
- {
- Current,
- Previous
- };
-
- //! menubar data
- class MenuBarData: public AnimationData
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- MenuBarData( QObject* parent, QWidget* target );
-
- //! destructor
- virtual ~MenuBarData( void )
- {}
-
- protected:
-
- bool _isMenu;
- int _motions;
-
- };
-
- //! menubar data
- class MenuBarDataV1: public MenuBarData
- {
-
- Q_OBJECT
-
- //! declare opacity property
- Q_PROPERTY( qreal currentOpacity READ currentOpacity WRITE setCurrentOpacity )
- Q_PROPERTY( qreal previousOpacity READ previousOpacity WRITE setPreviousOpacity )
-
- public:
-
- //! constructor
- MenuBarDataV1( QObject* parent, QWidget* target, int duration );
-
- //! destructor
- virtual ~MenuBarDataV1( void )
- {}
-
- //! event filter
- virtual bool eventFilter( QObject*, QEvent* );
-
- //! animations
- virtual const Animation::Pointer& currentAnimation( void ) const
- { return _current._animation; }
-
- //! animations
- virtual const Animation::Pointer& previousAnimation( void ) const
- { return _previous._animation; }
-
- //! return animation matching given point
- virtual Animation::Pointer animation( const QPoint& point ) const
- {
- if( currentRect().contains( point ) ) return currentAnimation();
- else if( previousRect().contains( point ) ) return previousAnimation();
- else return Animation::Pointer();
- }
-
- //! return animation matching given point
- virtual qreal opacity( const QPoint& point ) const
- {
- if( currentRect().contains( point ) ) return currentOpacity();
- else if( previousRect().contains( point ) ) return previousOpacity();
- else return OpacityInvalid;
- }
-
- // return rect matching QPoint
- virtual QRect currentRect( const QPoint& point ) const
- {
- if( currentRect().contains( point ) ) return currentRect();
- else if( previousRect().contains( point ) ) return previousRect();
- else return QRect();
- }
-
- //! animation associated to given Widget index
- virtual const Animation::Pointer& animation( WidgetIndex index ) const
- { return index == Current ? currentAnimation():previousAnimation(); }
-
- //! opacity associated to given Widget index
- virtual qreal opacity( WidgetIndex index ) const
- { return index == Current ? currentOpacity():previousOpacity(); }
-
- //! opacity associated to given Widget index
- virtual const QRect& currentRect( WidgetIndex index ) const
- { return index == Current ? currentRect():previousRect(); }
-
- //! duration
- virtual void setDuration( int duration )
- {
- currentAnimation().data()->setDuration( duration );
- previousAnimation().data()->setDuration( duration );
- }
-
- //! current opacity
- virtual qreal currentOpacity( void ) const
- { return _current._opacity; }
-
- //! current opacity
- virtual void setCurrentOpacity( qreal value )
- {
- value = digitize( value );
- if( _current._opacity == value ) return;
- _current._opacity = value;
- setDirty();
- }
-
- //! current rect
- virtual const QRect& currentRect( void ) const
- { return _current._rect; }
-
- //! previous opacity
- virtual qreal previousOpacity( void ) const
- { return _previous._opacity; }
-
- //! previous opacity
- virtual void setPreviousOpacity( qreal value )
- {
- value = digitize( value );
- if( _previous._opacity == value ) return;
- _previous._opacity = value;
- setDirty();
- }
-
- //! previous rect
- virtual const QRect& previousRect( void ) const
- { return _previous._rect; }
-
- protected:
-
- //!@name current action handling
- //@{
-
- //! guarded action pointer
- typedef QWeakPointer<QAction> ActionPointer;
-
- //! current action
- virtual const ActionPointer& currentAction( void ) const
- { return _currentAction; }
-
- //! current action
- virtual void setCurrentAction( QAction* action )
- { _currentAction = ActionPointer( action ); }
-
- //! current action
- virtual void clearCurrentAction( void )
- { _currentAction = ActionPointer(); }
-
- //@}
-
- //!@name rect handling
- //@{
-
- //! current rect
- virtual void setCurrentRect( const QRect& rect )
- { _current._rect = rect; }
-
- //! current rect
- virtual void clearCurrentRect( void )
- { _current._rect = QRect(); }
-
- //! previous rect
- virtual void setPreviousRect( const QRect& rect )
- { _previous._rect = rect; }
-
- //! previous rect
- virtual void clearPreviousRect( void )
- { _previous._rect = QRect(); }
-
- //@}
-
- // leave event
- template< typename T > inline void enterEvent( const QObject* object );
-
- // leave event
- template< typename T > inline void leaveEvent( const QObject* object );
-
- //! mouse move event
- template< typename T > inline void mouseMoveEvent( const QObject* object );
-
- //! mouse move event
- template< typename T > inline void mousePressEvent( const QObject* object );
-
- //! menubar enterEvent
- virtual void enterEvent( const QObject* object )
- { enterEvent<QMenuBar>( object ); }
-
- //! menubar enterEvent
- virtual void leaveEvent( const QObject* object )
- { leaveEvent<QMenuBar>( object ); }
-
- //! menubar mouseMoveEvent
- virtual void mouseMoveEvent( const QObject* object )
- { mouseMoveEvent<QMenuBar>( object ); }
-
- //! menubar mousePressEvent
- virtual void mousePressEvent( const QObject* object )
- { mousePressEvent<QMenuBar>( object ); }
-
- private:
-
- //! container for needed animation data
- class Data
- {
- public:
-
- //! default constructor
- Data( void ):
- _opacity(0)
- {}
-
- Animation::Pointer _animation;
- qreal _opacity;
- QRect _rect;
- };
-
- //! current tab animation data (for hover enter animations)
- Data _current;
-
- //! previous tab animations data (for hover leave animations)
- Data _previous;
-
- //! current action
- ActionPointer _currentAction;
-
- };
-
-
- //! menubar data
- class MenuBarDataV2: public MenuBarData
- {
-
- Q_OBJECT
- Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity )
- Q_PROPERTY( qreal progress READ progress WRITE setProgress )
-
- public:
-
- //! constructor
- MenuBarDataV2( QObject* parent, QWidget* target, int duration );
-
- //! destructor
- virtual ~MenuBarDataV2( void )
- {}
-
- //! event filter
- virtual bool eventFilter( QObject*, QEvent* );
-
- //! return animation associated to action at given position, if any
- virtual const Animation::Pointer& animation( void ) const
- { return _animation; }
-
- //! return animation associated to action at given position, if any
- virtual const Animation::Pointer& progressAnimation( void ) const
- { return _progressAnimation; }
-
- //! duration
- virtual void setDuration( int duration )
- { animation().data()->setDuration( duration ); }
-
- //! duration
- virtual void setFollowMouseDuration( int duration )
- { progressAnimation().data()->setDuration( duration ); }
-
- //! return 'hover' rect position when widget is animated
- virtual const QRect& animatedRect( void ) const
- { return _animatedRect; }
-
- //! current rect
- virtual const QRect& currentRect( void ) const
- { return _currentRect; }
-
- //! timer
- const QBasicTimer& timer( void ) const
- { return _timer; }
-
- //! animation opacity
- virtual qreal opacity( void ) const
- { return _opacity; }
-
- //! animation opacity
- virtual void setOpacity( qreal value )
- {
- value = digitize( value );
- if( _opacity == value ) return;
- _opacity = value;
- setDirty();
- }
-
- //! animation progress
- virtual qreal progress( void ) const
- { return _progress; }
-
- //! animation progress
- virtual void setProgress( qreal value )
- {
- value = digitize( value );
- if( _progress == value ) return;
- _progress = value;
- updateAnimatedRect();
- }
-
- protected:
-
- virtual void setEntered( bool value )
- { _entered = value; }
-
- //! animated rect
- virtual void clearAnimatedRect( void )
- { _animatedRect = QRect(); }
-
- //! updated animated rect
- virtual void updateAnimatedRect( void );
-
- //! timer event
- virtual void timerEvent( QTimerEvent* );
-
- //!@name current action handling
- //@{
-
- //! guarded action pointer
- typedef QWeakPointer<QAction> ActionPointer;
-
- //! current action
- virtual const ActionPointer& currentAction( void ) const
- { return _currentAction; }
-
- //! current action
- virtual void setCurrentAction( QAction* action )
- { _currentAction = ActionPointer( action ); }
-
- //! current action
- virtual void clearCurrentAction( void )
- { _currentAction = ActionPointer(); }
-
- //@}
-
- //!@name rect handling
- //@{
-
- //! current rect
- virtual void setCurrentRect( const QRect& rect )
- { _currentRect = rect; }
-
- //! current rect
- virtual void clearCurrentRect( void )
- { _currentRect = QRect(); }
-
- //! previous rect
- virtual const QRect& previousRect( void ) const
- { return _previousRect; }
-
- //! previous rect
- virtual void setPreviousRect( const QRect& rect )
- { _previousRect = rect; }
-
- //! previous rect
- virtual void clearPreviousRect( void )
- { _previousRect = QRect(); }
-
- //@}
-
- // leave event
- template< typename T > inline void enterEvent( const QObject* object );
-
- // leave event
- template< typename T > inline void leaveEvent( const QObject* object );
-
- //! mouse move event
- template< typename T > inline void mouseMoveEvent( const QObject* object );
-
- //! menubar enterEvent
- virtual void enterEvent( const QObject* object )
- { enterEvent<QMenuBar>( object ); }
-
- //! menubar enterEvent
- virtual void leaveEvent( const QObject* object )
- { leaveEvent<QMenuBar>( object ); }
-
- //! menubar mouseMoveEvent
- virtual void mouseMoveEvent( const QObject* object )
- { mouseMoveEvent<QMenuBar>( object ); }
-
- private:
-
- //! fade animation
- Animation::Pointer _animation;
-
- //! progress animation
- Animation::Pointer _progressAnimation;
-
- //! opacity
- qreal _opacity;
-
- //! opacity
- qreal _progress;
-
- //! timer
- /*! this allows to add some delay before starting leaveEvent animation */
- QBasicTimer _timer;
-
- //! current action
- ActionPointer _currentAction;
-
- // current rect
- QRect _currentRect;
-
- // previous rect
- QRect _previousRect;
-
- // animated rect
- QRect _animatedRect;
-
- //! true if toolbar was entered at least once (this prevents some initialization glitches)
- bool _entered;
-
- };
-}
-
-#include "oxygenmenubardata_imp.h"
-#endif
+++ /dev/null
-#ifndef oxygenmenubardata_imp_h
-#define oxygenmenubardata_imp_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenmenubardata_imp.h
-// implements menubar data templatized methods
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-namespace Oxygen
-{
-
- //________________________________________________________________________
- template< typename T > void MenuBarDataV1::enterEvent( const QObject* object )
- {
-
- const T* local = qobject_cast<const T*>( object );
- if( !local ) return;
-
- // if the current action is still active, one does nothing
- if( local->activeAction() == currentAction().data() ) return;
-
- if( currentAnimation().data()->isRunning() ) currentAnimation().data()->stop();
- clearCurrentAction();
- clearCurrentRect();
-
- }
-
- //________________________________________________________________________
- template< typename T > void MenuBarDataV1::leaveEvent( const QObject* object )
- {
-
- const T* local = qobject_cast<const T*>( object );
- if( !local ) return;
-
- // if the current action is still active, one does nothing
- if( local->activeAction() == currentAction().data() ) return;
-
- if( currentAnimation().data()->isRunning() ) currentAnimation().data()->stop();
- if( previousAnimation().data()->isRunning() ) previousAnimation().data()->stop();
- if( currentAction() )
- {
- setPreviousRect( currentRect() );
- clearCurrentAction();
- clearCurrentRect();
- previousAnimation().data()->start();
- }
-
- // trigger update
- setDirty();
-
- }
-
- //________________________________________________________________________
- template< typename T > void MenuBarDataV1::mouseMoveEvent( const QObject* object )
- {
-
- const T* local = qobject_cast<const T*>( object );
- if( !local ) return;
-
- // check action
- if( local->activeAction() == currentAction().data() ) return;
-
- bool hasCurrentAction( currentAction() );
-
- // check current action
- if( currentAction() )
- {
- if( currentAnimation().data()->isRunning() ) currentAnimation().data()->stop();
- if( previousAnimation().data()->isRunning() ) previousAnimation().data()->stop();
-
- // only start fadeout effect if there is no new selected action
- //if( !activeActionValid )
- if( !local->activeAction() )
- {
- setPreviousRect( currentRect() );
- previousAnimation().data()->start();
- }
-
- clearCurrentAction();
- clearCurrentRect();
-
- }
-
- // check if local current actions is valid
- bool activeActionValid( local->activeAction() && local->activeAction()->isEnabled() && !local->activeAction()->isSeparator() );
- if( activeActionValid )
- {
- if( currentAnimation().data()->isRunning() ) currentAnimation().data()->stop();
-
- setCurrentAction( local->activeAction() );
- setCurrentRect( local->actionGeometry( currentAction().data() ) );
- if( !hasCurrentAction )
- { currentAnimation().data()->start(); }
-
- }
-
- }
-
- //________________________________________________________________________
- template< typename T > void MenuBarDataV1::mousePressEvent( const QObject* object )
- {
-
- const T* local = qobject_cast<const T*>( object );
- if( !local ) return;
-
- // check action
- if( local->activeAction() == currentAction().data() ) return;
-
- // check current action
- bool activeActionValid( local->activeAction() && local->activeAction()->isEnabled() && !local->activeAction()->isSeparator() );
- if( currentAction() && !activeActionValid )
- {
-
- if( currentAnimation().data()->isRunning() ) currentAnimation().data()->stop();
- if( previousAnimation().data()->isRunning() ) previousAnimation().data()->stop();
-
- setPreviousRect( currentRect() );
- previousAnimation().data()->start();
-
- clearCurrentAction();
- clearCurrentRect();
-
- }
-
- }
-
- //________________________________________________________________________
- template< typename T > void MenuBarDataV2::enterEvent( const QObject* object )
- {
-
- // cast widget
- const T* local = qobject_cast<const T*>( object );
- if( !local ) return;
-
- if( _timer.isActive() ) _timer.stop();
-
- // if the current action is still active, one does nothing
- if( currentAction() && local->activeAction() == currentAction().data() ) return;
-
- if( animation().data()->isRunning() ) animation().data()->stop();
- if( progressAnimation().data()->isRunning() ) progressAnimation().data()->stop();
- clearPreviousRect();
- clearAnimatedRect();
-
- if( local->activeAction() && local->activeAction()->isEnabled() && !local->activeAction()->isSeparator() )
- {
- setCurrentAction( local->activeAction() );
- setCurrentRect( local->actionGeometry( currentAction().data() ) );
- animation().data()->setDirection( Animation::Forward );
- animation().data()->start();
-
- } else {
-
- clearCurrentAction();
- clearCurrentRect();
-
- }
-
- return;
- }
-
- //________________________________________________________________________
- template< typename T > void MenuBarDataV2::leaveEvent( const QObject* object )
- {
-
- const T* local = qobject_cast<const T*>( object );
- if( !local ) return;
-
- // if the current action is still active, one does nothing
- if( local->activeAction() && local->activeAction() == currentAction().data() )
- { return; }
-
- if( progressAnimation().data()->isRunning() ) progressAnimation().data()->stop();
- if( animation().data()->isRunning() ) animation().data()->stop();
- clearAnimatedRect();
- clearPreviousRect();
- if( currentAction() )
- {
- clearCurrentAction();
- animation().data()->setDirection( Animation::Backward );
- animation().data()->start();
- }
-
- // trigger update
- setDirty();
-
- return;
-
- }
-
- //________________________________________________________________________
- template< typename T > void MenuBarDataV2::mouseMoveEvent( const QObject* object )
- {
- const T* local = qobject_cast<const T*>( object );
- if( !local ) return;
- if( local->activeAction() == currentAction().data() ) return;
-
- // check if current position match another action
- if( local->activeAction() && local->activeAction()->isEnabled() && !local->activeAction()->isSeparator())
- {
-
- if( _timer.isActive() ) _timer.stop();
-
- QAction* activeAction( local->activeAction() );
-
- // update previous rect if the current action is valid
- QRect activeRect( local->actionGeometry( activeAction ) );
- if( currentAction() )
- {
- if( !progressAnimation().data()->isRunning() )
- {
-
- setPreviousRect( currentRect() );
-
- } else if( progress() < 1 && currentRect().isValid() && previousRect().isValid() ) {
-
- // re-calculate previous rect so that animatedRect
- // is unchanged after currentRect is updated
- // this prevents from having jumps in the animation
- qreal ratio = progress()/(1.0-progress());
- _previousRect.adjust(
- ratio*( currentRect().left() - activeRect.left() ),
- ratio*( currentRect().top() - activeRect.top() ),
- ratio*( currentRect().right() - activeRect.right() ),
- ratio*( currentRect().bottom() - activeRect.bottom() ) );
-
- }
-
- // update current action
- setCurrentAction( activeAction );
- setCurrentRect( activeRect );
- if( animation().data()->isRunning() ) animation().data()->stop();
- if( !progressAnimation().data()->isRunning() ) progressAnimation().data()->start();
-
- } else {
-
- // update current action
- setCurrentAction( activeAction );
- setCurrentRect( activeRect );
- if( !_entered )
- {
-
- _entered = true;
- if( animation().data()->isRunning() ) animation().data()->stop();
- if( !progressAnimation().data()->isRunning() ) progressAnimation().data()->start();
-
- } else {
-
- setPreviousRect( activeRect );
- clearAnimatedRect();
- if( progressAnimation().data()->isRunning() ) progressAnimation().data()->stop();
- animation().data()->setDirection( Animation::Forward );
- if( !animation().data()->isRunning() ) animation().data()->start();
- }
-
- }
-
- } else if( currentAction() ) {
-
- _timer.start( 150, this );
-
- }
-
- return;
-
- }
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenmenubarengine.cpp
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenmenubarengine.h"
-#include "oxygenmenubarengine.moc"
-
-#include <QtCore/QEvent>
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- MenuBarEngineV1::MenuBarEngineV1( QObject* parent, MenuBarBaseEngine* other ):
- MenuBarBaseEngine( parent )
- {
- if( other )
- {
- foreach( QWidget* widget, other->registeredWidgets() )
- { registerWidget( widget ); }
- }
- }
-
- //____________________________________________________________
- bool MenuBarEngineV1::registerWidget( QWidget* widget )
- {
-
- if( !widget ) return false;
-
- // create new data class
- if( !_data.contains( widget ) ) _data.insert( widget, new MenuBarDataV1( this, widget, duration() ), enabled() );
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
- return true;
-
- }
-
- //____________________________________________________________
- bool MenuBarEngineV1::isAnimated( const QObject* object, const QPoint& position )
- {
- DataMap<MenuBarDataV1>::Value data( _data.find( object ) );
- if( !data ) return false;
- if( Animation::Pointer animation = data.data()->animation( position ) ) return animation.data()->isRunning();
- else return false;
- }
-
- //____________________________________________________________
- BaseEngine::WidgetList MenuBarEngineV1::registeredWidgets( void ) const
- {
-
- WidgetList out ;
-
- // the typedef is needed to make Krazy happy
- typedef DataMap<MenuBarDataV1>::Value Value;
- foreach( const Value& value, _data )
- { if( value ) out.insert( value.data()->target().data() ); }
-
- return out;
-
- }
-
- //____________________________________________________________
- MenuBarEngineV2::MenuBarEngineV2( QObject* parent, MenuBarBaseEngine* other ):
- MenuBarBaseEngine( parent ),
- _followMouseDuration( 150 )
- {
- if( other )
- {
- foreach( QWidget* widget, other->registeredWidgets() )
- { registerWidget( widget ); }
- }
- }
-
- //____________________________________________________________
- bool MenuBarEngineV2::registerWidget( QWidget* widget )
- {
-
- if( !widget ) return false;
-
- // create new data class
- if( !_data.contains( widget ) )
- {
- DataMap<MenuBarDataV2>::Value value( new MenuBarDataV2( this, widget, duration() ) );
- value.data()->setFollowMouseDuration( followMouseDuration() );
- _data.insert( widget, value, enabled() );
- }
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
- return true;
-
- }
-
-
- //____________________________________________________________
- bool MenuBarEngineV2::isAnimated( const QObject* object, const QPoint& )
- {
- if( !enabled() ) return false;
- DataMap<MenuBarDataV2>::Value data( _data.find( object ) );
- if( !data ) return false;
- if( data.data()->animation() && data.data()->animation().data()->isRunning() ) return true;
- else if( Animation::Pointer animation = data.data()->progressAnimation() ) return animation.data()->isRunning();
- else return false;
-
- }
-
- //____________________________________________________________
- QRect MenuBarEngineV2::currentRect( const QObject* object, const QPoint& )
- {
- if( !enabled() ) return QRect();
- DataMap<MenuBarDataV2>::Value data( _data.find( object ) );
- return data ? data.data()->currentRect():QRect();
- }
-
- //____________________________________________________________
- QRect MenuBarEngineV2::animatedRect( const QObject* object )
- {
- if( !enabled() ) return QRect();
- DataMap<MenuBarDataV2>::Value data( _data.find( object ) );
- return data ? data.data()->animatedRect():QRect();
-
- }
-
- //____________________________________________________________
- bool MenuBarEngineV2::isTimerActive( const QObject* object )
- {
- if( !enabled() ) return false;
- DataMap<MenuBarDataV2>::Value data( _data.find( object ) );
- return data ? data.data()->timer().isActive():false;
- }
-
- //____________________________________________________________
- BaseEngine::WidgetList MenuBarEngineV2::registeredWidgets( void ) const
- {
-
- WidgetList out;
-
- // the typedef is needed to make Krazy happy
- typedef DataMap<MenuBarDataV2>::Value Value;
- foreach( const Value& value, _data )
- { if( value ) out.insert( value.data()->target().data() ); }
-
- return out;
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenmenubarengine_h
-#define oxygenmenubarengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenmenubarengine.h
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygenmenubardata.h"
-
-namespace Oxygen
-{
-
- //! stores menubar hovered action and timeLine
- class MenuBarBaseEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit MenuBarBaseEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~MenuBarBaseEngine( void )
- {}
-
- //! register menubar
- virtual bool registerWidget( QWidget* ) = 0;
-
- //! true if widget is animated
- virtual bool isAnimated( const QObject*, const QPoint& )
- { return false; }
-
- //! animation opacity
- virtual qreal opacity( const QObject*, const QPoint& )
- { return -1; }
-
- //! return 'hover' rect position when widget is animated
- virtual QRect currentRect( const QObject*, const QPoint& )
- { return QRect(); }
-
- //! animated rect
- virtual QRect animatedRect( const QObject* )
- { return QRect(); }
-
- //! timer
- virtual bool isTimerActive( const QObject* )
- { return false; }
-
- //! enability
- virtual void setEnabled( bool ) = 0;
-
- //! duration
- virtual void setDuration( int ) = 0;
-
- //! duration
- virtual void setFollowMouseDuration( int )
- {}
-
- };
-
- //! fading menubar animation
- class MenuBarEngineV1: public MenuBarBaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit MenuBarEngineV1( QObject* parent ):
- MenuBarBaseEngine( parent )
- {}
-
- //! constructor
- MenuBarEngineV1( QObject* parent, MenuBarBaseEngine* other );
-
- //! destructor
- virtual ~MenuBarEngineV1( void )
- {}
-
- //! register menubar
- virtual bool registerWidget( QWidget* );
-
- //! true if widget is animated
- virtual bool isAnimated( const QObject* object, const QPoint& point );
-
- //! animation opacity
- virtual qreal opacity( const QObject* object, const QPoint& point )
- { return isAnimated( object, point ) ? _data.find( object ).data()->opacity( point ): AnimationData::OpacityInvalid; }
-
- //! return 'hover' rect position when widget is animated
- virtual QRect currentRect( const QObject* object, const QPoint& point)
- { return isAnimated( object, point ) ? _data.find( object ).data()->currentRect( point ): QRect(); }
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int duration )
- {
- BaseEngine::setDuration( duration );
- _data.setDuration( duration );
- }
-
- //! return list of registered widgets
- virtual WidgetList registeredWidgets( void ) const;
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! data map
- DataMap<MenuBarDataV1> _data;
-
- };
-
- //! follow-mouse menubar animation
- class MenuBarEngineV2: public MenuBarBaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit MenuBarEngineV2( QObject* parent ):
- MenuBarBaseEngine( parent )
- {}
-
- //! constructor
- MenuBarEngineV2( QObject* parent, MenuBarBaseEngine* other );
-
- //! destructor
- virtual ~MenuBarEngineV2( void )
- {}
-
- //! register menubar
- virtual bool registerWidget( QWidget* );
-
-
- //! true if widget is animated
- virtual bool isAnimated( const QObject* object, const QPoint& point );
-
- //! animation opacity
- virtual qreal opacity( const QObject* object, const QPoint& point )
- { return isAnimated( object, point ) ? _data.find( object ).data()->opacity(): AnimationData::OpacityInvalid; }
-
- //! return 'hover' rect position when widget is animated
- virtual QRect currentRect( const QObject*, const QPoint& );
-
- //! return 'hover' rect position when widget is animated
- virtual QRect animatedRect( const QObject* );
-
- //! timer associated to the data
- virtual bool isTimerActive( const QObject* );
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- //! duration
- virtual int followMouseDuration( void ) const
- { return _followMouseDuration; }
-
- //! duration
- virtual void setFollowMouseDuration( int duration )
- {
- _followMouseDuration = duration;
- foreach( const DataMap<MenuBarDataV2>::Value& value, _data )
- { if( value ) value.data()->setFollowMouseDuration( duration ); }
- }
-
- //! return list of registered widgets
- virtual WidgetList registeredWidgets( void ) const;
-
- protected slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! follow mouse animation duration
- int _followMouseDuration;
-
- //! data map
- DataMap<MenuBarDataV2> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenmenudata.cpp
-// data container for QMenu animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenmenudata.h"
-#include "oxygenmenudata.moc"
+++ /dev/null
-#ifndef oxygenmenu_datah
-#define oxygenmenu_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenmenudata.h
-// data container for QMenu animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenmenubardata.h"
-#include <QtGui/QMenu>
-
-namespace Oxygen
-{
-
- //! menubar data
- /*!
- most members are identical to menubar data. The one that are not are
- using templatized versions, because QMenuBar and QMenu API are very similar
- */
- class MenuDataV1: public MenuBarDataV1
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- MenuDataV1( QObject* parent, QWidget* target, int duration ):
- MenuBarDataV1( parent, target, duration )
- {}
-
- //! destructor
- virtual ~MenuDataV1( void )
- {}
-
- protected:
-
- //! menubar enterEvent
- virtual void enterEvent( const QObject* object )
- { MenuBarDataV1::enterEvent<QMenu>( object ); }
-
- //! menubar enterEvent
- virtual void leaveEvent( const QObject* object )
- { MenuBarDataV1::leaveEvent<QMenu>( object ); }
-
- //! menubar mouseMoveEvent
- virtual void mouseMoveEvent( const QObject* object )
- { MenuBarDataV1::mouseMoveEvent<QMenu>( object ); }
-
- //! menubar mousePressEvent
- virtual void mousePressEvent( const QObject* object )
- { MenuBarDataV1::mousePressEvent<QMenu>( object ); }
-
- };
-
- //! menubar data
- /*!
- most members are identical to menubar data. The one that are not are
- using templatized versions, because QMenuBar and QMenu API are very similar
- */
- class MenuDataV2: public MenuBarDataV2
- {
-
- Q_OBJECT
-
- public:
- //! constructor
- MenuDataV2( QObject* parent, QWidget* target, int duration ):
- MenuBarDataV2( parent, target, duration )
- { setEntered( false ); }
-
- //! destructor
- virtual ~MenuDataV2( void )
- {}
-
- protected:
-
- //! menubar enterEvent
- virtual void enterEvent( const QObject* object )
- { MenuBarDataV2::enterEvent<QMenu>( object ); }
-
- //! menubar enterEvent
- virtual void leaveEvent( const QObject* object )
- { MenuBarDataV2::leaveEvent<QMenu>( object ); }
-
- //! menubar mouseMoveEvent
- virtual void mouseMoveEvent( const QObject* object )
- { MenuBarDataV2::mouseMoveEvent<QMenu>( object ); }
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenmenuengine.cpp
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenmenuengine.h"
-#include "oxygenmenuengine.moc"
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- MenuEngineV1::MenuEngineV1( QObject* parent, MenuBaseEngine* other ):
- MenuBaseEngine( parent )
- {
- if( other )
- {
- foreach( QWidget* widget, other->registeredWidgets() )
- { registerWidget( widget ); }
- }
- }
-
- //____________________________________________________________
- bool MenuEngineV1::registerWidget( QWidget* widget )
- {
-
- if( !widget ) return false;
-
- // create new data class
- if( !_data.contains( widget ) ) _data.insert( widget, new MenuDataV1( this, widget, duration() ), enabled() );
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
- return true;
- }
-
- //____________________________________________________________
- bool MenuEngineV1::isAnimated( const QObject* object, WidgetIndex index )
- {
- DataMap<MenuDataV1>::Value data( _data.find( object ) );
- if( !data )
- {
- return false;
- }
-
- if( Animation::Pointer animation = data.data()->animation( index ) ) {
-
- return animation.data()->isRunning();
-
- } else return false;
- }
-
- //____________________________________________________________
- BaseEngine::WidgetList MenuEngineV1::registeredWidgets( void ) const
- {
-
- WidgetList out;
-
- // the typedef is needed to make Krazy happy
- typedef DataMap<MenuDataV1>::Value Value;
- foreach( const Value& value, _data )
- { if( value ) out.insert( value.data()->target().data() ); }
-
- return out;
-
- }
-
- //____________________________________________________________
- MenuEngineV2::MenuEngineV2( QObject* parent, MenuBaseEngine* other ):
- MenuBaseEngine( parent ),
- _followMouseDuration( 150 )
- {
- if( other )
- {
- foreach( QWidget* widget, other->registeredWidgets() )
- { registerWidget( widget ); }
- }
- }
-
- //____________________________________________________________
- bool MenuEngineV2::registerWidget( QWidget* widget )
- {
-
- if( !widget ) return false;
-
- // create new data class
- if( !_data.contains( widget ) )
- {
- DataMap<MenuDataV2>::Value value( new MenuDataV2( this, widget, duration() ) );
- value.data()->setFollowMouseDuration( followMouseDuration() );
- _data.insert( widget, value, enabled() );
- }
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
-
- return true;
- }
-
- //____________________________________________________________
- QRect MenuEngineV2::currentRect( const QObject* object, WidgetIndex )
- {
- if( !enabled() ) return QRect();
- DataMap<MenuDataV2>::Value data( _data.find( object ) );
- return data ? data.data()->currentRect():QRect();
-
- }
-
- //____________________________________________________________
- bool MenuEngineV2::isAnimated( const QObject* object, WidgetIndex index )
- {
- DataMap<MenuDataV2>::Value data( _data.find( object ) );
- if( !data )
- {
- return false;
- }
-
- switch( index )
- {
- case Oxygen::Previous:
- {
- if( Animation::Pointer animation = data.data()->animation() )
- {
- return animation.data()->direction() == Animation::Backward && animation.data()->isRunning();
- } else return false;
- }
-
- case Oxygen::Current:
- {
- if( data.data()->animation() && data.data()->animation().data()->isRunning() ) return true;
- else return false;
- }
-
- default: return false;
-
- }
-
- }
-
- //____________________________________________________________
- QRect MenuEngineV2::animatedRect( const QObject* object )
- {
- if( !enabled() ) return QRect();
- DataMap<MenuDataV2>::Value data( _data.find( object ) );
- return data ? data.data()->animatedRect():QRect();
-
- }
-
- //____________________________________________________________
- bool MenuEngineV2::isTimerActive( const QObject* object )
- {
- if( !enabled() ) return false;
- DataMap<MenuDataV2>::Value data( _data.find( object ) );
- return data ? data.data()->timer().isActive():false;
-
- }
-
- //____________________________________________________________
- BaseEngine::WidgetList MenuEngineV2::registeredWidgets( void ) const
- {
-
- WidgetList out;
-
- // the typedef is needed to make Krazy happy
- typedef DataMap<MenuDataV2>::Value Value;
- foreach( const Value& value, _data )
- { if( value ) out.insert( value.data()->target().data() ); }
-
- return out;
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenmenuengine_h
-#define oxygenmenuengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenmenuengine.h
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygenmenudata.h"
-
-namespace Oxygen
-{
-
- //! stores menu hovered action and timeLine
- class MenuBaseEngine: public BaseEngine
- {
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit MenuBaseEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~MenuBaseEngine( void )
- {}
-
- //! register menubar
- virtual bool registerWidget( QWidget* ) = 0;
-
- //! true if widget is animated
- virtual bool isAnimated( const QObject*, WidgetIndex )
- { return false; }
-
- //! opacity
- virtual qreal opacity( const QObject*, WidgetIndex )
- { return -1; }
-
- //! return 'hover' rect position when widget is animated
- virtual QRect currentRect( const QObject*, WidgetIndex )
- { return QRect(); }
-
- //! return 'hover' rect position when widget is animated
- virtual QRect animatedRect( const QObject* )
- { return QRect(); }
-
- //! timer associated to the data
- virtual bool isTimerActive( const QObject* )
- { return false; }
-
- //! enability
- virtual void setEnabled( bool value ) = 0;
-
- //! duration
- virtual void setDuration( int ) = 0;
-
- //! duration
- virtual void setFollowMouseDuration( int )
- {}
-
- };
-
- //! stores menu hovered action and timeLine
- class MenuEngineV1: public MenuBaseEngine
- {
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit MenuEngineV1( QObject* parent ):
- MenuBaseEngine( parent )
- {}
-
- //! constructor
- MenuEngineV1( QObject* parent, MenuBaseEngine* other );
-
- //! destructor
- virtual ~MenuEngineV1( void )
- {}
-
- //! register menubar
- virtual bool registerWidget( QWidget* );
-
- //! true if widget is animated
- virtual bool isAnimated( const QObject* object, WidgetIndex index );
-
- //! animation opacity
- virtual qreal opacity( const QObject* object, WidgetIndex index )
- {
- if( !isAnimated( object, index ) ) return AnimationData::OpacityInvalid;
- else return _data.find(object).data()->opacity( index );
- }
-
- //! return 'hover' rect position when widget is animated
- virtual QRect currentRect( const QObject* object, WidgetIndex index )
- {
- if( !isAnimated( object, index ) ) return QRect();
- else return _data.find(object).data()->currentRect( index );
- }
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int duration )
- {
- BaseEngine::setDuration( duration );
- _data.setDuration( duration );
- }
-
- //! return list of registered widgets
- virtual WidgetList registeredWidgets( void ) const;
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! data map
- DataMap<MenuDataV1> _data;
-
- };
-
- //! stores menu hovered action and timeLine
- class MenuEngineV2: public MenuBaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit MenuEngineV2( QObject* parent ):
- MenuBaseEngine( parent )
- {}
-
- //! destructor
- virtual ~MenuEngineV2( void )
- {}
-
- //! constructor
- MenuEngineV2( QObject* parent, MenuBaseEngine* other );
-
- //! register menu
- virtual bool registerWidget( QWidget* );
-
- //! return timeLine associated to action at given position, if any
- virtual bool isAnimated( const QObject*, WidgetIndex );
-
- //! animation opacity
- virtual qreal opacity( const QObject* object, WidgetIndex index )
- {
- if( !isAnimated( object, index ) ) return AnimationData::OpacityInvalid;
- else return _data.find(object).data()->opacity();
- }
-
- //! return 'hover' rect position when widget is animated
- virtual QRect currentRect( const QObject* object, WidgetIndex index );
-
- //! return 'hover' rect position when widget is animated
- virtual QRect animatedRect( const QObject* );
-
- //! timer associated to the data
- virtual bool isTimerActive( const QObject* );
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- //! duration
- virtual int followMouseDuration( void ) const
- { return _followMouseDuration; }
-
- //! duration
- virtual void setFollowMouseDuration( int duration )
- {
- _followMouseDuration = duration;
- foreach( const DataMap<MenuDataV2>::Value& value, _data )
- { if( value ) value.data()->setFollowMouseDuration( duration ); }
- }
-
- //! return list of registered widgets
- virtual WidgetList registeredWidgets( void ) const;
-
- protected slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! follow mouse animation duration
- int _followMouseDuration;
-
- //! data map
- DataMap<MenuDataV2> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenprogressbar.cpp
-// data container for progressbar animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenprogressbardata.h"
-#include "oxygenprogressbardata.moc"
-
-#include <QtGui/QProgressBar>
-#include <cassert>
-
-namespace Oxygen
-{
-
- //______________________________________________
- ProgressBarData::ProgressBarData( QObject* parent, QWidget* target, int duration ):
- GenericData( parent, target, duration ),
- _startValue(0),
- _endValue(0)
- {
-
- target->installEventFilter( this );
-
- // set animation curve shape
- animation().data()->setEasingCurve( QEasingCurve::InOutQuad );
-
- // make sure target is a progressbar and store relevant values
- QProgressBar* progress = qobject_cast<QProgressBar*>( target );
- assert( progress );
- setStartValue( progress->value() );
- setEndValue( progress->value() );
-
- // setup connections
- connect( target, SIGNAL(valueChanged(int)), SLOT(valueChanged(int)) );
-
- }
-
- //______________________________________________
- bool ProgressBarData::eventFilter( QObject* object, QEvent* event )
- {
-
- if( !( enabled() && object && object == target().data() ) ) return AnimationData::eventFilter( object, event );
- switch( event->type() )
- {
- case QEvent::Show:
- {
-
- // reset start and end value
- QProgressBar* progress = static_cast<QProgressBar*>( target().data() );
- setStartValue( progress->value() );
- setEndValue( progress->value() );
- break;
-
- }
-
- case QEvent::Hide:
- {
- if( animation().data()->isRunning() )
- { animation().data()->stop(); }
- break;
- }
-
- default: break;
-
- }
-
- return AnimationData::eventFilter( object, event );
-
- }
-
- //______________________________________________
- void ProgressBarData::valueChanged( int value )
- {
-
- // do nothing if not enabled
- if( !enabled() ) return;
-
- // do nothing if progress is invalid
- QProgressBar* progress = static_cast<QProgressBar*>( target().data() );
- if( !( progress && progress->maximum() != progress->minimum() ) ) return;
-
- // update start and end values
- bool isRunning( animation().data()->isRunning() );
- if( isRunning )
- {
-
- // in case next value arrives while animation is running,
- // end animation, set value immediately
- // and trigger target update. This increases responsiveness of progressbars
- setStartValue( value );
- setEndValue( value );
- animation().data()->stop();
- setOpacity(0);
-
- if( target() ) target().data()->update();
-
- return;
-
- }
-
- setStartValue( endValue() );
- setEndValue( value );
-
- // start animation only if target is enabled, visible, not running,
- // and if end and start values are different enough
- // (with end value being larger than start value)
- if( !(target() && target().data()->isEnabled() && target().data()->isVisible()) ) return;
- if( isRunning || endValue()-startValue() < 2 ) return;
-
- animation().data()->start();
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenprogressbar_datah
-#define oxygenprogressbar_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenprogressbardata.h
-// data container for progressbar animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygengenericdata.h"
-#include <QtCore/QObject>
-#include <QtCore/QTextStream>
-
-namespace Oxygen
-{
-
-
- //! generic data
- class ProgressBarData: public GenericData
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- ProgressBarData( QObject* parent, QWidget* widget, int duration );
-
- //! destructor
- virtual ~ProgressBarData( void )
- {}
-
- //! event filter
- virtual bool eventFilter( QObject*, QEvent* );
-
- //! progressbar value (during animation)
- virtual int value( void ) const
- { return startValue() + opacity()*( endValue() - startValue() ); }
-
- protected slots:
-
- //! triggered by progressBar::valueChanged
- void valueChanged( int );
-
- protected:
-
- const int& startValue( void ) const
- { return _startValue; }
-
- void setStartValue( int value )
- { _startValue = value; }
-
- const int& endValue( void ) const
- { return _endValue; }
-
- void setEndValue( int value )
- { _endValue = value; }
-
- private:
-
- //! animation starting value
- int _startValue;
-
- //! animation ending value
- int _endValue;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenprogressbarengine.cpp
-// handle progress bar animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenprogressbarengine.h"
-#include "oxygenprogressbarengine.moc"
-
-namespace Oxygen
-{
-
- //_______________________________________________
- const char* const ProgressBarEngine::busyValuePropertyName = "_kde_oxygen_busy_value";
-
- //_______________________________________________
- bool ProgressBarEngine::registerWidget( QWidget* widget )
- {
-
- // check enability
- if( !widget ) return false;
-
- // create new data class
- if( !_data.contains( widget ) ) _data.insert( widget, new ProgressBarData( this, widget, duration() ), enabled() );
- if( busyIndicatorEnabled() && !_dataSet.contains( widget ) )
- {
- widget->setProperty( busyValuePropertyName, 0 );
- _dataSet.insert( widget );
- }
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
-
- return true;
-
- }
-
- //____________________________________________________________
- bool ProgressBarEngine::isAnimated( const QObject* object )
- {
-
- DataMap<ProgressBarData>::Value data( ProgressBarEngine::data( object ) );
- return ( data && data.data()->animation() && data.data()->animation().data()->isRunning() );
-
- }
-
- //____________________________________________________________
- void ProgressBarEngine::setBusyStepDuration( int value )
- {
- if( _busyStepDuration == value ) return;
- _busyStepDuration = value;
-
- // restart timer with specified time
- if( _timer.isActive() )
- {
- _timer.stop();
- _timer.start( busyStepDuration(), this );
- }
-
- }
-
- //_______________________________________________
- void ProgressBarEngine::timerEvent( QTimerEvent* event )
- {
-
- // check enability and timer
- if( !(busyIndicatorEnabled() && event->timerId() == _timer.timerId() ) )
- { return BaseEngine::timerEvent( event ); }
-
- bool animated( false );
-
- // loop over objects in map
- for( ProgressBarSet::iterator iter = _dataSet.begin(); iter != _dataSet.end(); ++iter )
- {
-
- // cast to progressbar
- QProgressBar* progressBar( qobject_cast<QProgressBar*>( *iter ) );
-
- // check cast, visibility and range
- if( progressBar && progressBar->isVisible() && progressBar->minimum() == 0 && progressBar->maximum() == 0 )
- {
-
- // update animation flag
- animated = true;
-
- // update value
- progressBar->setProperty( busyValuePropertyName, progressBar->property( busyValuePropertyName ).toInt()+1 );
- progressBar->update();
-
- } else if( *iter ) { (*iter)->setProperty( busyValuePropertyName, 0 ); }
-
- }
-
- if( !animated ) _timer.stop();
-
- }
-
- //____________________________________________________________
- DataMap<ProgressBarData>::Value ProgressBarEngine::data( const QObject* object )
- { return _data.find( object ).data(); }
-
-}
+++ /dev/null
-#ifndef oxygenprogressbarengine_h
-#define oxygenprogressbarengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenprogressbarengine.h
-// handle progress bar animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygenprogressbardata.h"
-#include "oxygendatamap.h"
-
-#include <QtCore/QBasicTimer>
-#include <QtCore/QSet>
-#include <QtCore/QObject>
-#include <QtCore/QTimerEvent>
-#include <QtGui/QWidget>
-#include <QtGui/QProgressBar>
-
-namespace Oxygen
-{
-
- //! handles progress bar animations
- class ProgressBarEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! busy value property name
- static const char* const busyValuePropertyName;
-
- //! constructor
- explicit ProgressBarEngine( QObject* object ):
- BaseEngine( object ),
- _busyIndicatorEnabled( true ),
- _busyStepDuration( 50 )
- {}
-
- //! destructor
- virtual ~ProgressBarEngine( void )
- {}
-
- //! register menubar
- virtual bool registerWidget( QWidget* );
-
- //! true if widget is animated
- virtual bool isAnimated( const QObject* object );
-
- //! animation opacity
- virtual int value( const QObject* object )
- { return isAnimated( object ) ? data( object ).data()->value():0 ; }
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- //! busy indicator enability
- virtual void setBusyIndicatorEnabled( bool value )
- { _busyIndicatorEnabled = value; }
-
- virtual bool busyIndicatorEnabled( void ) const
- { return _busyIndicatorEnabled; }
-
- //! busy indicator step duration
- virtual void setBusyStepDuration( int value );
-
- //! busy indicator step duration
- virtual int busyStepDuration( void ) const
- { return _busyStepDuration; }
-
- //! start busy timer
- virtual void startBusyTimer( void )
- {
- if( !_timer.isActive() )
- { _timer.start( busyStepDuration(), this ); }
- }
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- {
- if( !object ) return false;
- _dataSet.remove( object );
- return _data.unregisterWidget( object );
- }
-
- protected:
-
- //! timer event
- virtual void timerEvent( QTimerEvent* );
-
- //! returns data associated to widget
- DataMap<ProgressBarData>::Value data( const QObject* );
-
- private:
-
- //! map widgets to progressbar data
- DataMap<ProgressBarData> _data;
-
- //! store set of of progress bars
- typedef QSet<QObject*> ProgressBarSet;
- ProgressBarSet _dataSet;
-
- //! busy indicator enabled
- bool _busyIndicatorEnabled;
-
- //! busy indicator step duration
- int _busyStepDuration;
-
- //! timer
- QBasicTimer _timer;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenscrollbardata.cpp
-// data container for QTabBar animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenscrollbardata.h"
-#include "oxygenscrollbardata.moc"
-
-#include <QtGui/QHoverEvent>
-#include <QtGui/QScrollBar>
-#include <QtGui/QStyleOptionSlider>
-
-Q_GUI_EXPORT QStyleOptionSlider qt_qscrollbarStyleOption(QScrollBar*);
-
-namespace Oxygen
-{
-
- //______________________________________________
- ScrollBarData::ScrollBarData( QObject* parent, QWidget* target, int duration ):
- SliderData( parent, target, duration ),
- _position( -1, -1 )
- {
-
- target->installEventFilter( this );
-
- _addLineData._animation = new Animation( duration, this );
- _subLineData._animation = new Animation( duration, this );
-
- connect( addLineAnimation().data(), SIGNAL(finished()), SLOT(clearAddLineRect()) );
- connect( subLineAnimation().data(), SIGNAL(finished()), SLOT(clearSubLineRect()) );
-
- // setup animation
- setupAnimation( addLineAnimation(), "addLineOpacity" );
- setupAnimation( subLineAnimation(), "subLineOpacity" );
-
- }
-
- //______________________________________________
- bool ScrollBarData::eventFilter( QObject* object, QEvent* event )
- {
-
- if( object != target().data() )
- { return SliderData::eventFilter( object, event ); }
-
- // check event type
- switch( event->type() )
- {
-
- case QEvent::HoverEnter:
- case QEvent::HoverMove:
- hoverMoveEvent( object, event );
- break;
-
- case QEvent::HoverLeave:
- hoverLeaveEvent( object, event );
- break;
-
- default: break;
-
- }
-
- return SliderData::eventFilter( object, event );
-
- }
-
- //______________________________________________
- const Animation::Pointer& ScrollBarData::animation( QStyle::SubControl subcontrol ) const
- {
- switch( subcontrol )
- {
- default:
- case QStyle::SC_ScrollBarSlider:
- return animation();
-
- case QStyle::SC_ScrollBarAddLine:
- return addLineAnimation();
-
- case QStyle::SC_ScrollBarSubLine:
- return subLineAnimation();
- }
-
- }
-
- //______________________________________________
- qreal ScrollBarData::opacity( QStyle::SubControl subcontrol ) const
- {
- switch( subcontrol )
- {
- default:
- case QStyle::SC_ScrollBarSlider:
- return opacity();
-
- case QStyle::SC_ScrollBarAddLine:
- return addLineOpacity();
-
- case QStyle::SC_ScrollBarSubLine:
- return subLineOpacity();
- }
-
- }
-
- //______________________________________________
- void ScrollBarData::hoverMoveEvent( QObject* object, QEvent* event )
- {
-
- // try cast object to scrollbar
- QScrollBar* scrollBar( qobject_cast<QScrollBar*>( object ) );
- if( !scrollBar || scrollBar->isSliderDown() ) return;
-
- // retrieve scrollbar option
- QStyleOptionSlider opt( qt_qscrollbarStyleOption( qobject_cast<QScrollBar*>( object ) ) );
-
- // cast event
- QHoverEvent *hoverEvent = static_cast<QHoverEvent*>(event);
- QStyle::SubControl hoverControl = scrollBar->style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, hoverEvent->pos(), scrollBar);
-
- // update hover state
- updateAddLineArrow( hoverControl );
- updateSubLineArrow( hoverControl );
-
- // store position
- _position = hoverEvent->pos();
-
- }
-
-
- //______________________________________________
- void ScrollBarData::hoverLeaveEvent( QObject* object, QEvent* event )
- {
- Q_UNUSED( object );
- Q_UNUSED( event );
-
- // reset hover state
- updateSubLineArrow( QStyle::SC_None );
- updateAddLineArrow( QStyle::SC_None );
-
- // reset mouse position
- _position = QPoint( -1, -1 );
- }
-
- //_____________________________________________________________________
- void ScrollBarData::updateSubLineArrow( QStyle::SubControl hoverControl )
- {
- if( hoverControl == QStyle::SC_ScrollBarSubLine )
- {
-
- if( !subLineArrowHovered() )
- {
- setSubLineArrowHovered( true );
- if( enabled() )
- {
- subLineAnimation().data()->setDirection( Animation::Forward );
- if( !subLineAnimation().data()->isRunning() ) subLineAnimation().data()->start();
- } else setDirty();
- }
-
- } else {
-
- if( subLineArrowHovered() )
- {
- setSubLineArrowHovered( false );
- if( enabled() )
- {
- subLineAnimation().data()->setDirection( Animation::Backward );
- if( !subLineAnimation().data()->isRunning() ) subLineAnimation().data()->start();
- } else setDirty();
- }
-
- }
- }
-
- //_____________________________________________________________________
- void ScrollBarData::updateAddLineArrow( QStyle::SubControl hoverControl )
- {
- if( hoverControl == QStyle::SC_ScrollBarAddLine )
- {
-
- if( !addLineArrowHovered() )
- {
- setAddLineArrowHovered( true );
- if( enabled() )
- {
- addLineAnimation().data()->setDirection( Animation::Forward );
- if( !addLineAnimation().data()->isRunning() ) addLineAnimation().data()->start();
- } else setDirty();
- }
-
- } else {
-
- if( addLineArrowHovered() )
- {
- setAddLineArrowHovered( false );
- if( enabled() )
- {
- addLineAnimation().data()->setDirection( Animation::Backward );
- if( !addLineAnimation().data()->isRunning() ) addLineAnimation().data()->start();
- } else setDirty();
- }
-
- }
- }
-
-}
+++ /dev/null
-#ifndef oxygenscrollbar_datah
-#define oxygenscrollbar_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenscrollbardata.h
-// data container for QScrollBar animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygensliderdata.h"
-
-namespace Oxygen
-{
-
- //! scrollbar data
- class ScrollBarData: public SliderData
- {
-
- Q_OBJECT
- Q_PROPERTY( qreal addLineOpacity READ addLineOpacity WRITE setAddLineOpacity )
- Q_PROPERTY( qreal subLineOpacity READ subLineOpacity WRITE setSubLineOpacity )
-
- public:
-
- //! constructor
- ScrollBarData( QObject* parent, QWidget* target, int );
-
- //! destructor
- virtual ~ScrollBarData( void )
- {}
-
- //! event filter
- virtual bool eventFilter( QObject*, QEvent* );
-
- //! needed to avoid warning about virtual function being hidden
- using SliderData::animation;
- using SliderData::opacity;
-
- //! return animation for a given subcontrol
- virtual const Animation::Pointer& animation( QStyle::SubControl ) const;
-
- //! 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
- {
- switch( control )
- {
- case QStyle::SC_ScrollBarAddLine: return _addLineData._rect;
- case QStyle::SC_ScrollBarSubLine: return _subLineData._rect;
- default: return QRect();
- }
- }
-
-
- //! subcontrol rect
- virtual void setSubControlRect( QStyle::SubControl control, const QRect& rect )
- {
- switch( control )
- {
- case QStyle::SC_ScrollBarAddLine:
- _addLineData._rect = rect;
- break;
-
- case QStyle::SC_ScrollBarSubLine:
- _subLineData._rect = rect;
- break;
-
- default: break;
- }
- }
-
- //! duration
- virtual void setDuration( int duration )
- {
- SliderData::setDuration( duration );
- addLineAnimation().data()->setDuration( duration );
- subLineAnimation().data()->setDuration( duration );
- }
-
- //! addLine opacity
- virtual void setAddLineOpacity( qreal value )
- {
- value = digitize( value );
- if( _addLineData._opacity == value ) return;
- _addLineData._opacity = value;
- setDirty();
- }
-
- //! addLine opacity
- virtual qreal addLineOpacity( void ) const
- { return _addLineData._opacity; }
-
- //! subLine opacity
- virtual void setSubLineOpacity( qreal value )
- {
- value = digitize( value );
- if( _subLineData._opacity == value ) return;
- _subLineData._opacity = value;
- setDirty();
- }
-
- //! subLine opacity
- virtual qreal subLineOpacity( void ) const
- { return _subLineData._opacity; }
-
- //! mouse position
- QPoint position( void ) const
- { return _position; }
-
- protected slots:
-
- //! clear addLineRect
- void clearAddLineRect( void )
- {
- if( addLineAnimation().data()->direction() == Animation::Backward )
- { _addLineData._rect = QRect(); }
- }
-
- //! clear subLineRect
- void clearSubLineRect( void )
- {
- if( subLineAnimation().data()->direction() == Animation::Backward )
- { _subLineData._rect = QRect(); }
- }
-
- protected:
-
- //! hoverMoveEvent
- virtual void hoverMoveEvent( QObject*, QEvent* );
-
- //! hoverMoveEvent
- virtual void hoverLeaveEvent( QObject*, QEvent* );
-
- //!@name hover flags
- //@{
-
- virtual bool addLineArrowHovered( void ) const
- { return _addLineData._hovered; }
-
- virtual void setAddLineArrowHovered( bool value )
- { _addLineData._hovered = value; }
-
- virtual bool subLineArrowHovered( void ) const
- { return _subLineData._hovered; }
-
- virtual void setSubLineArrowHovered( bool value )
- { _subLineData._hovered = value; }
-
- //@}
-
- //! update add line arrow
- virtual void updateAddLineArrow( QStyle::SubControl );
-
- //! update sub line arrow
- virtual void updateSubLineArrow( QStyle::SubControl );
-
- //!@name timelines
- //@{
-
- virtual const Animation::Pointer& addLineAnimation( void ) const
- { return _addLineData._animation; }
-
- virtual const Animation::Pointer& subLineAnimation( void ) const
- { return _subLineData._animation; }
-
- private:
-
- //! stores arrow data
- class Data
- {
-
- public:
-
- //! constructor
- Data( void ):
- _hovered( false ),
- _opacity( AnimationData::OpacityInvalid )
- {}
-
- //! true if hovered
- bool _hovered;
-
- //! animation
- Animation::Pointer _animation;
-
- //! opacity
- qreal _opacity;
-
- //! rect
- QRect _rect;
-
- };
-
-
- //! add line data (down arrow)
- Data _addLineData;
-
- //! subtract line data (up arrow)
- Data _subLineData;
-
- //! mouse position
- QPoint _position;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenscrollbarengine.cpp
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenscrollbarengine.h"
-#include "oxygenscrollbarengine.moc"
-
-#include <QtCore/QEvent>
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- bool ScrollBarEngine::registerWidget( QWidget* widget )
- {
-
- // 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() ), enabled() );
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
- return true;
- }
-
-
- //____________________________________________________________
- bool ScrollBarEngine::isAnimated( const QObject* object, QStyle::SubControl control )
- {
-
- if( DataMap<ScrollBarData>::Value data = _data.find( object ) )
- {
- if( Animation::Pointer animation = data.data()->animation( control ) ) return animation.data()->isRunning();
-
- }
-
- return false;
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenscrollbarengine_h
-#define oxygenscrollbarengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenscrollbarengine.h
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygenscrollbardata.h"
-
-namespace Oxygen
-{
-
- //! stores scrollbar hovered action and timeLine
- class ScrollBarEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit ScrollBarEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~ScrollBarEngine( void )
- {}
-
- //! register scrollbar
- virtual bool registerWidget( QWidget* );
-
- //! true if widget is animated
- virtual bool isAnimated( const QObject* object, QStyle::SubControl control );
-
- //! animation opacity
- 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 )
- {
- if( DataMap<ScrollBarData>::Value data = _data.find( object ) ) return data.data()->subControlRect( control );
- else return QRect();
- }
-
- //! control rect
- virtual void setSubControlRect( const QObject* object, QStyle::SubControl control, const QRect& rect )
- {
- if( DataMap<ScrollBarData>::Value data = _data.find( object ) )
- { data.data()->setSubControlRect( control, rect ); }
- }
-
- //! control rect
- virtual void updateState( const QObject* object, bool state )
- {
- if( DataMap<ScrollBarData>::Value data = _data.find( object ) )
- { data.data()->updateState( state ); }
- }
-
- //! mouse position
- virtual QPoint position( const QObject* object )
- {
- if( DataMap<ScrollBarData>::Value data = _data.find( object ) ) return data.data()->position();
- else return QPoint( -1, -1 );
- }
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::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
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! data map
- DataMap<ScrollBarData> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygensliderdata.cpp
-// data container for QSlider animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygensliderdata.h"
-#include "oxygensliderdata.moc"
-
-#include <QtGui/QHoverEvent>
-#include <QtGui/QSlider>
-#include <QtGui/QStyleOptionSlider>
-
-Q_GUI_EXPORT QStyleOptionSlider qt_qsliderStyleOption(QSlider*);
-
-
-namespace Oxygen
-{
-
- //______________________________________________
- bool SliderData::updateState( bool state )
- {
- if( state == _sliderHovered ) return false;
- updateSlider( state ? QStyle::SC_SliderHandle : QStyle::SC_None );
- return true;
- }
-
- //_____________________________________________________________________
- void SliderData::updateSlider( QStyle::SubControl hoverControl )
- {
-
- if( hoverControl == QStyle::SC_SliderHandle )
- {
-
- if( !sliderHovered() ) {
- setSliderHovered( true );
- if( enabled() )
- {
- animation().data()->setDirection( Animation::Forward );
- if( !animation().data()->isRunning() ) animation().data()->start();
- } else setDirty();
- }
-
- } else {
-
- if( sliderHovered() )
- {
- setSliderHovered( false );
- if( enabled() )
- {
- animation().data()->setDirection( Animation::Backward );
- if( !animation().data()->isRunning() ) animation().data()->start();
- } else setDirty();
- }
-
- }
- }
-
-}
+++ /dev/null
-#ifndef oxygenslider_datah
-#define oxygenslider_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygensliderdata.h
-// data container for QSlider animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygengenericdata.h"
-
-#include <QtGui/QStyle>
-#include <QtGui/QStyleOptionSlider>
-
-namespace Oxygen
-{
-
- //! scrollbar data
- class SliderData: public GenericData
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- SliderData( QObject* parent, QWidget* target, int duration ):
- GenericData( parent, target, duration ),
- _sliderHovered( false )
- {}
-
- //! destructor
- virtual ~SliderData( void )
- {}
-
- //! update state
- virtual bool updateState( bool );
-
- protected:
-
- //! hover
- virtual bool sliderHovered( void ) const
- { return _sliderHovered; }
-
- //! hover
- virtual void setSliderHovered( bool value )
- { _sliderHovered = value; }
-
- //! update slider
- virtual void updateSlider( QStyle::SubControl );
-
- private:
-
- //! true when slider is hovered
- bool _sliderHovered;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygensliderengine.cpp
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygensliderengine.h"
-#include "oxygensliderengine.moc"
-
-#include <QtCore/QEvent>
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- bool SliderEngine::registerWidget( QWidget* widget )
- {
-
- if( !widget ) return false;
-
- // create new data class
- if( !_data.contains( widget ) ) _data.insert( widget, new SliderData( this, widget, duration() ), enabled() );
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
- return true;
-
- }
-
-}
+++ /dev/null
-#ifndef oxygensliderengine_h
-#define oxygensliderengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygensliderengine.h
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygensliderdata.h"
-
-namespace Oxygen
-{
-
- //! stores slider hovered action and timeLine
- class SliderEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit SliderEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~SliderEngine( void )
- {}
-
- //! register slider
- virtual bool registerWidget( QWidget* );
-
- //! true if widget is animated
- virtual bool isAnimated( const QObject* object )
- {
- if( DataMap<SliderData>::Value data = _data.find( object ) )
- {
-
- return data.data()->animation().data()->isRunning();
-
- } else return false;
-
- }
-
- //! update state
- virtual bool updateState( const QObject* object, bool state )
- {
-
- if( DataMap<SliderData>::Value data = _data.find( object ) )
- {
-
- return data.data()->updateState( state );
-
- } else return false;
-
- }
-
- //! animation opacity
- virtual qreal opacity( const QObject* object )
- { return isAnimated( object ) ? _data.find( object ).data()->opacity() : AnimationData::OpacityInvalid; }
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! data map
- DataMap<SliderData> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenspinboxdata.cpp
-// spinbox data container for up/down arrow hover (mouse-over) animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenspinboxdata.h"
-#include "oxygenspinboxdata.moc"
-
-namespace Oxygen
-{
-
- //________________________________________________
- SpinBoxData::SpinBoxData( QObject* parent, QWidget* target, int duration ):
- AnimationData( parent, target )
- {
- _upArrowData._animation = new Animation( duration, this );
- _downArrowData._animation = new Animation( duration, this );
- setupAnimation( upArrowAnimation(), "upArrowOpacity" );
- setupAnimation( downArrowAnimation(), "downArrowOpacity" );
- }
-
- //______________________________________________
- bool SpinBoxData::Data::updateState( bool value )
- {
- if( _state == value ) return false;
- else {
-
- _state = value;
- _animation.data()->setDirection( _state ? Animation::Forward : Animation::Backward );
- if( !_animation.data()->isRunning() ) _animation.data()->start();
- return true;
-
- }
- }
-
-}
+++ /dev/null
-#ifndef oxygenspinbox_datah
-#define oxygenspinbox_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenspinboxdata.h
-// spinbox data container for up/down arrow hover (mouse-over) animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimationdata.h"
-
-#include <QtGui/QStyle>
-
-namespace Oxygen
-{
-
- //! handles spinbox arrows hover
- class SpinBoxData: public AnimationData
- {
-
- Q_OBJECT
-
- //! declare opacity property
- Q_PROPERTY( qreal upArrowOpacity READ upArrowOpacity WRITE setUpArrowOpacity )
- Q_PROPERTY( qreal downArrowOpacity READ downArrowOpacity WRITE setDownArrowOpacity )
-
- public:
-
- //! constructor
- SpinBoxData( QObject*, QWidget*, int );
-
- //! destructor
- virtual ~SpinBoxData( void )
- {}
-
- //! animation state
- virtual bool updateState( QStyle::SubControl subControl, bool value )
- {
- if( subControl == QStyle::SC_SpinBoxUp ) return _upArrowData.updateState( value );
- else if( subControl == QStyle::SC_SpinBoxDown ) return _downArrowData.updateState( value );
- else return false;
- }
-
- //! animation state
- virtual bool isAnimated( QStyle::SubControl subControl ) const
- {
- return(
- ( subControl == QStyle::SC_SpinBoxUp && upArrowAnimation().data()->isRunning() ) ||
- ( subControl == QStyle::SC_SpinBoxDown && downArrowAnimation().data()->isRunning() ) );
- }
-
- //! opacity
- virtual qreal opacity( QStyle::SubControl subControl ) const
- {
- if( subControl == QStyle::SC_SpinBoxUp ) return upArrowOpacity();
- else if( subControl == QStyle::SC_SpinBoxDown ) return downArrowOpacity();
- else return OpacityInvalid;
- }
-
- //! duration
- virtual void setDuration( int duration )
- {
- upArrowAnimation().data()->setDuration( duration );
- downArrowAnimation().data()->setDuration( duration );
- }
-
- //!@name up arrow animation
- //@{
-
- //! opacity
- qreal upArrowOpacity( void ) const
- { return _upArrowData._opacity; }
-
- //! opacity
- void setUpArrowOpacity( qreal value )
- {
- value = digitize( value );
- if( _upArrowData._opacity == value ) return;
- _upArrowData._opacity = value;
- setDirty();
- }
-
- //! animation
- Animation::Pointer upArrowAnimation( void ) const
- { return _upArrowData._animation; }
-
- //@}
-
- //!@name down arrow animation
- //@{
-
- //! opacity
- qreal downArrowOpacity( void ) const
- { return _downArrowData._opacity; }
-
- //! opacity
- void setDownArrowOpacity( qreal value )
- {
- value = digitize( value );
- if( _downArrowData._opacity == value ) return;
- _downArrowData._opacity = value;
- setDirty();
- }
-
- //! animation
- Animation::Pointer downArrowAnimation( void ) const
- { return _downArrowData._animation; }
-
- //@}
-
- private:
-
- //! container for needed animation data
- class Data
- {
-
- public:
-
- //! default constructor
- Data( void ):
- _state( false ),
- _opacity(0)
- {}
-
- //! state
- bool updateState( bool );
-
- //! arrow state
- bool _state;
-
- //! animation
- Animation::Pointer _animation;
-
- //! opacity
- qreal _opacity;
-
- };
-
- //! up arrow data
- Data _upArrowData;
-
- //! down arrow data
- Data _downArrowData;
-
- };
-
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenspinboxengine.cpp
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenspinboxengine.h"
-#include "oxygenspinboxengine.moc"
-
-#include <QtCore/QEvent>
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- bool SpinBoxEngine::registerWidget( QWidget* widget )
- {
-
- if( !widget ) return false;
-
- // create new data class
- if( !_data.contains( widget ) ) _data.insert( widget, new SpinBoxData( this, widget, duration() ), enabled() );
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
- return true;
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenspinboxengine_h
-#define oxygenspinboxengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenspinboxengine.h
-// stores event filters and maps widgets to animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygenspinboxdata.h"
-
-namespace Oxygen
-{
-
- //! handle spinbox arrows hover effect
- class SpinBoxEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit SpinBoxEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~SpinBoxEngine( void )
- {}
-
- //! register widget
- virtual bool registerWidget( QWidget* );
-
- //! state
- virtual bool updateState( const QObject* object, QStyle::SubControl subControl, bool value )
- {
- if( DataMap<SpinBoxData>::Value data = _data.find( object ) )
- {
- return data.data()->updateState( subControl, value );
- } else return false;
- }
-
- //! true if widget is animated
- virtual bool isAnimated( const QObject* object, QStyle::SubControl subControl )
- {
- if( DataMap<SpinBoxData>::Value data = _data.find( object ) )
- {
- return data.data()->isAnimated( subControl );
- } else return false;
-
- }
-
- //! animation opacity
- virtual qreal opacity( const QObject* object, QStyle::SubControl subControl )
- {
- if( DataMap<SpinBoxData>::Value data = _data.find( object ) )
- {
- return data.data()->opacity( subControl );
- } else return AnimationData::OpacityInvalid;
- }
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! data map
- DataMap<SpinBoxData> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygensplitterengine.h
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-
-#include "oxygensplitterengine.h"
-#include "oxygensplitterengine.moc"
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- bool SplitterEngine::registerWidget( QWidget* widget )
- {
-
- if( !widget ) return false;
- if( !_data.contains( widget ) ) { _data.insert( widget, new WidgetStateData( this, widget, duration() ), enabled() ); }
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
- return true;
-
- }
-
- //____________________________________________________________
- bool SplitterEngine::updateState( const QPaintDevice* object, bool value )
- {
- PaintDeviceDataMap<WidgetStateData>::Value data( SplitterEngine::data( object ) );
- return ( data && data.data()->updateState( value ) );
- }
-
- //____________________________________________________________
- bool SplitterEngine::isAnimated( const QPaintDevice* object )
- {
-
- PaintDeviceDataMap<WidgetStateData>::Value data( SplitterEngine::data( object ) );
- return ( data && data.data()->animation() && data.data()->animation().data()->isRunning() );
-
- }
-
-}
+++ /dev/null
-#ifndef oxygensplitterengine_h
-#define oxygensplitterengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygensplitterengine.h
-// QSplitter engine
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygenwidgetstatedata.h"
-
-namespace Oxygen
-{
-
- //! QSplitter animation engine
- class SplitterEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit SplitterEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~SplitterEngine( void )
- {}
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- //! register widget
- virtual bool registerWidget( QWidget* );
-
- //! true if widget hover state is changed
- virtual bool updateState( const QPaintDevice*, bool );
-
- //! true if widget is animated
- virtual bool isAnimated( const QPaintDevice* );
-
- //! animation opacity
- virtual qreal opacity( const QPaintDevice* object )
- { return isAnimated( object ) ? data( object ).data()->opacity(): AnimationData::OpacityInvalid; }
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* data )
- {
-
- if( !data ) return false;
-
- // reinterpret_cast is safe here since only the address is used to find
- // data in the map
- return _data.unregisterWidget( reinterpret_cast<QPaintDevice*>(data) );
-
- }
-
- protected:
-
- //! returns data associated to widget
- PaintDeviceDataMap<WidgetStateData>::Value data( const QPaintDevice* object )
- { return _data.find( object ).data(); }
-
- private:
-
- //! engine enability
- bool _enabled;
-
- //! animation duration
- int _duration;
-
- //! map
- PaintDeviceDataMap<WidgetStateData> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-// krazy:excludeall=qclasses
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygentabbardata.cpp
-// data container for QTabBar animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygentabbardata.h"
-#include "oxygentabbardata.moc"
-
-#include <QtGui/QHoverEvent>
-#include <QtGui/QTabBar>
-
-namespace Oxygen
-{
-
- //______________________________________________
- TabBarData::TabBarData( QObject* parent, QWidget* target, int duration ):
- AnimationData( parent, target )
- {
-
- _current._animation = new Animation( duration, this );
- setupAnimation( currentIndexAnimation(), "currentOpacity" );
- currentIndexAnimation().data()->setDirection( Animation::Forward );
-
- _previous._animation = new Animation( duration, this );
- setupAnimation( previousIndexAnimation(), "previousOpacity" );
- previousIndexAnimation().data()->setDirection( Animation::Backward );
-
- }
-
- //______________________________________________
- Animation::Pointer TabBarData::animation( const QPoint& position ) const
- {
-
- if( !enabled() ) return Animation::Pointer();
-
- const QTabBar* local( qobject_cast<const QTabBar*>( target().data() ) );
- if( !local ) return Animation::Pointer();
-
- int index( local->tabAt( position ) );
- if( index < 0 ) return Animation::Pointer();
- else if( index == currentIndex() ) return currentIndexAnimation();
- else if( index == previousIndex() ) return previousIndexAnimation();
- else return Animation::Pointer();
-
- }
-
- //______________________________________________
- bool TabBarData::updateState( const QPoint& position , bool hovered )
- {
-
- if( !enabled() ) return false;
-
- const QTabBar* local( qobject_cast<const QTabBar*>( target().data() ) );
- if( !local ) return false;
-
- int index( local->tabAt( position ) );
- if( index < 0 ) return false;
-
- if( hovered )
- {
-
-
- if( index != currentIndex() )
- {
-
- if( currentIndex() >= 0 )
- {
- setPreviousIndex( currentIndex() );
- setCurrentIndex( -1 );
- previousIndexAnimation().data()->restart();
- }
-
- setCurrentIndex( index );
- currentIndexAnimation().data()->restart();
- return true;
-
- } else return false;
-
- } else if( index == currentIndex() ) {
-
- setPreviousIndex( currentIndex() );
- setCurrentIndex( -1 );
- previousIndexAnimation().data()->restart();
- return true;
-
- } else return false;
-
- }
-
- //______________________________________________
- qreal TabBarData::opacity( const QPoint& position ) const
- {
-
- if( !enabled() ) return OpacityInvalid;
-
- const QTabBar* local( qobject_cast<const QTabBar*>( target().data() ) );
- if( !local ) return OpacityInvalid;
-
- int index( local->tabAt( position ) );
- if( index < 0 ) return OpacityInvalid;
- else if( index == currentIndex() ) return currentOpacity();
- else if( index == previousIndex() ) return previousOpacity();
- else return OpacityInvalid;
-
- }
-
-
-}
+++ /dev/null
-#ifndef oxygentabbar_datah
-#define oxygentabbar_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygentabbardata.h
-// data container for QTabBar animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimationdata.h"
-
-#include <QtGui/QTabBar>
-
-namespace Oxygen
-{
-
- //! tabbars
- class TabBarData: public AnimationData
- {
-
- Q_OBJECT
-
- //! declare opacity property
- Q_PROPERTY( qreal currentOpacity READ currentOpacity WRITE setCurrentOpacity )
- Q_PROPERTY( qreal previousOpacity READ previousOpacity WRITE setPreviousOpacity )
-
- public:
-
- //! constructor
- TabBarData( QObject* parent, QWidget* target, int duration );
-
- //! destructor
- virtual ~TabBarData( void )
- {}
-
- //! duration
- void setDuration( int duration )
- {
- currentIndexAnimation().data()->setDuration( duration );
- previousIndexAnimation().data()->setDuration( duration );
- }
-
- //! update state
- bool updateState( const QPoint&, bool );
-
- //!@name current index handling
- //@{
-
- //! current opacity
- virtual qreal currentOpacity( void ) const
- { return _current._opacity; }
-
- //! current opacity
- virtual void setCurrentOpacity( qreal value )
- {
- if( _current._opacity == value ) return;
- _current._opacity = value;
- setDirty();
- }
-
- //! current index
- virtual int currentIndex( void ) const
- { return _current._index; }
-
- //! current index
- virtual void setCurrentIndex( int index )
- { _current._index = index; }
-
- //! current index animation
- virtual const Animation::Pointer& currentIndexAnimation( void ) const
- { return _current._animation; }
-
- //@}
-
- //!@name previous index handling
- //@{
-
- //! previous opacity
- virtual qreal previousOpacity( void ) const
- { return _previous._opacity; }
-
- //! previous opacity
- virtual void setPreviousOpacity( qreal value )
- {
- if( _previous._opacity == value ) return;
- _previous._opacity = value;
- setDirty();
- }
-
- //! previous index
- virtual int previousIndex( void ) const
- { return _previous._index; }
-
- //! previous index
- virtual void setPreviousIndex( int index )
- { _previous._index = index; }
-
- //! previous index Animation
- virtual const Animation::Pointer& previousIndexAnimation( void ) const
- { return _previous._animation; }
-
- //@}
-
- //! return Animation associated to action at given position, if any
- virtual Animation::Pointer animation( const QPoint& position ) const;
-
- //! return opacity associated to action at given position, if any
- virtual qreal opacity( const QPoint& position ) const;
-
- private:
-
- //! container for needed animation data
- class Data
- {
- public:
-
- //! default constructor
- Data( void ):
- _opacity(0),
- _index(-1)
- {}
-
- Animation::Pointer _animation;
- qreal _opacity;
- int _index;
- };
-
- //! current tab animation data (for hover enter animations)
- Data _current;
-
- //! previous tab animations data (for hover leave animations)
- Data _previous;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygentabbarengine.cpp
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygentabbarengine.h"
-#include "oxygentabbarengine.moc"
-
-#include <QtCore/QEvent>
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- bool TabBarEngine::registerWidget( QWidget* widget )
- {
-
- if( !widget ) return false;
-
- // create new data class
- if( !_data.contains( widget ) ) _data.insert( widget, new TabBarData( this, widget, duration() ), enabled() );
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
- return true;
-
- }
-
- //____________________________________________________________
- bool TabBarEngine::updateState( const QObject* object, const QPoint& position, bool value )
- {
- DataMap<TabBarData>::Value data( _data.find( object ) );
- return ( data && data.data()->updateState( position, value ) );
- }
-
-}
+++ /dev/null
-#ifndef oxygentabbarengine_h
-#define oxygentabbarengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygentabbarengine.h
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygentabbardata.h"
-
-namespace Oxygen
-{
-
- //! stores tabbar hovered action and timeLine
- class TabBarEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit TabBarEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~TabBarEngine( void )
- {}
-
- //! register tabbar
- virtual bool registerWidget( QWidget* );
-
- //! true if widget hover state is changed
- virtual bool updateState( const QObject*, const QPoint&, bool );
-
- //! true if widget is animated
- virtual bool isAnimated( const QObject* object, const QPoint& point )
- {
- if( DataMap<TabBarData>::Value data = _data.find( object ) )
- { if( Animation::Pointer animation = data.data()->animation( point ) ) return animation.data()->isRunning(); }
- return false;
- }
-
- //! animation opacity
- virtual qreal opacity( const QObject* object, const QPoint& point )
- { return isAnimated( object, point ) ? _data.find( object ).data()->opacity( point ) : AnimationData::OpacityInvalid; }
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! data map
- DataMap<TabBarData> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygentoolbardata.cpp
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygentoolbardata.h"
-#include "oxygentoolbardata.moc"
-
-#include <QtGui/QToolButton>
-
-namespace Oxygen
-{
-
- //________________________________________________________________________
- ToolBarData::ToolBarData( QObject* parent, QWidget* target, int duration ):
- AnimationData( parent, target ),
- _opacity( 0 ),
- _progress( 0 ),
- _currentObject( 0 ),
- _entered( false )
- {
-
- target->installEventFilter( this );
-
- _animation = new Animation( duration, this );
- animation().data()->setDirection( Animation::Forward );
- animation().data()->setStartValue( 0.0 );
- animation().data()->setEndValue( 1.0 );
- animation().data()->setTargetObject( this );
- animation().data()->setPropertyName( "opacity" );
-
- // progress animation
- _progressAnimation = new Animation( duration, this );
- progressAnimation().data()->setDirection( Animation::Forward );
- progressAnimation().data()->setStartValue( 0 );
- progressAnimation().data()->setEndValue( 1 );
- progressAnimation().data()->setTargetObject( this );
- progressAnimation().data()->setPropertyName( "progress" );
- progressAnimation().data()->setEasingCurve( QEasingCurve::Linear );
-
- // add all children widgets to event handler
- foreach( QObject* child, target->children() )
- { if( qobject_cast<QToolButton*>( child ) ) childAddedEvent( child ); }
-
- }
-
- //______________________________________________
- bool ToolBarData::eventFilter( QObject* object, QEvent* event )
- {
-
- // check object
- const QObject *targetData = target().data();
- if( object == targetData )
- {
-
- switch( event->type() )
- {
-
- case QEvent::Enter:
- {
- if( enabled() )
- {
- object->event( event );
- enterEvent( object );
- return true;
- } else return false;
- }
-
- case QEvent::ChildAdded:
- {
-
- // add children even in disabled case, to make sure they
- // are properly registered when engine is enabled
- QChildEvent* childEvent( static_cast<QChildEvent*>( event ) );
- childAddedEvent( childEvent->child() );
- break;
- }
-
- default: break;
-
- }
-
- } else if( object->parent() == targetData ) {
-
- if( !enabled() ) return false;
-
- switch( event->type() )
- {
-
- case QEvent::HoverEnter:
- childEnterEvent( object );
- break;
-
- case QEvent::HoverLeave:
- if( currentObject() && !_timer.isActive() ) _timer.start( 100, this );
- break;
-
- default:
- break;
-
- }
-
- }
-
- return false;
-
- }
-
- //____________________________________________________________
- void ToolBarData::updateAnimatedRect( void )
- {
-
- // check rect validity
- if( currentRect().isNull() || previousRect().isNull() )
- {
- _animatedRect = QRect();
- return;
- }
-
- // compute rect located 'between' previous and current
- _animatedRect.setLeft( previousRect().left() + progress()*(currentRect().left() - previousRect().left()) );
- _animatedRect.setRight( previousRect().right() + progress()*(currentRect().right() - previousRect().right()) );
- _animatedRect.setTop( previousRect().top() + progress()*(currentRect().top() - previousRect().top()) );
- _animatedRect.setBottom( previousRect().bottom() + progress()*(currentRect().bottom() - previousRect().bottom()) );
-
- // trigger update
- setDirty();
- return;
-
- }
-
- //________________________________________________________________________
- void ToolBarData::enterEvent( const QObject* )
- {
-
- if( _timer.isActive() ) _timer.stop();
- if( animation().data()->isRunning() ) animation().data()->stop();
- if( progressAnimation().data()->isRunning() ) progressAnimation().data()->stop();
- clearPreviousRect();
- clearAnimatedRect();
-
- return;
-
- }
-
-
- //________________________________________________________________________
- void ToolBarData::leaveEvent( const QObject* )
- {
-
- if( progressAnimation().data()->isRunning() ) progressAnimation().data()->stop();
- if( animation().data()->isRunning() ) animation().data()->stop();
- clearAnimatedRect();
- clearPreviousRect();
-
- if( currentObject() )
- {
-
- clearCurrentObject();
- animation().data()->setDirection( Animation::Backward );
- animation().data()->start();
-
- }
-
- return;
-
- }
-
- //________________________________________________________________________
- void ToolBarData::childEnterEvent( const QObject* object )
- {
-
- if( object == currentObject() ) return;
-
- const QToolButton* local = qobject_cast<const QToolButton*>( object );
-
- // check if current position match another action
- if( local && local->isEnabled() )
- {
-
- if( _timer.isActive() ) _timer.stop();
-
- // get rect
- QRect activeRect( local->rect().translated( local->mapToParent( QPoint(0,0) ) ) );
-
- // update previous rect if the current action is valid
- if( currentObject() )
- {
-
- if( !progressAnimation().data()->isRunning() )
- {
-
- setPreviousRect( currentRect() );
-
- } else if( progress() < 1 && currentRect().isValid() && previousRect().isValid() ) {
-
- // re-calculate previous rect so that animatedRect
- // is unchanged after currentRect is updated
- // this prevents from having jumps in the animation
- qreal ratio = progress()/(1.0-progress());
- _previousRect.adjust(
- ratio*( currentRect().left() - activeRect.left() ),
- ratio*( currentRect().top() - activeRect.top() ),
- ratio*( currentRect().right() - activeRect.right() ),
- ratio*( currentRect().bottom() - activeRect.bottom() ) );
-
- }
-
- // update current action
- setCurrentObject( local );
- setCurrentRect( activeRect );
- if( animation().data()->isRunning() ) animation().data()->stop();
- if( !progressAnimation().data()->isRunning() ) progressAnimation().data()->start();
-
- } else {
-
- setCurrentObject( local );
- setCurrentRect( activeRect );
- if( !_entered )
- {
-
- _entered = true;
- if( animation().data()->isRunning() ) animation().data()->stop();
- if( !progressAnimation().data()->isRunning() ) progressAnimation().data()->start();
-
- } else {
-
- setPreviousRect( activeRect );
- clearAnimatedRect();
- if( progressAnimation().data()->isRunning() ) progressAnimation().data()->stop();
- animation().data()->setDirection( Animation::Forward );
- if( !animation().data()->isRunning() ) animation().data()->start();
- }
-
- }
-
- } else if( currentObject() ) {
-
- if( !_timer.isActive() ) _timer.start( 100, this );
-
- }
-
- return;
-
- }
-
- //___________________________________________________________________
- void ToolBarData::childAddedEvent( QObject* object )
- {
- QWidget* widget( qobject_cast<QWidget*>( object ) );
- if( !widget ) return;
-
- // add connections
- connect( animation().data(), SIGNAL(valueChanged(QVariant)), widget, SLOT(update()), Qt::UniqueConnection );
- connect( progressAnimation().data(), SIGNAL(valueChanged(QVariant)), widget, SLOT(update()), Qt::UniqueConnection );
-
- // add event filter
- widget->removeEventFilter( this );
- widget->installEventFilter( this );
- }
-
- //___________________________________________________________
- void ToolBarData::timerEvent( QTimerEvent *event )
- {
-
- if( event->timerId() != _timer.timerId() ) return AnimationData::timerEvent( event );
- _timer.stop();
- leaveEvent( target().data() );
- }
-
-}
+++ /dev/null
-#ifndef oxygentoolbar_datah
-#define oxygentoolbar_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygentoolbardata.h
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimationdata.h"
-#include <QtCore/QBasicTimer>
-
-namespace Oxygen
-{
-
- //! toolbar data
- class ToolBarData: public AnimationData
- {
-
- Q_OBJECT
- Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity )
- Q_PROPERTY( qreal progress READ progress WRITE setProgress )
-
- public:
-
- //! constructor
- ToolBarData( QObject* parent, QWidget* target, int duration );
-
- //! destructor
- virtual ~ToolBarData( void )
- {}
-
- //! event filter
- virtual bool eventFilter( QObject*, QEvent* );
-
- //! return animation associated to action at given position, if any
- virtual const Animation::Pointer& animation( void ) const
- { return _animation; }
-
- //! return animation associated to action at given position, if any
- virtual const Animation::Pointer& progressAnimation( void ) const
- { return _progressAnimation; }
-
- //! duration
- virtual void setDuration( int duration )
- { animation().data()->setDuration( duration ); }
-
- //! duration
- virtual void setFollowMouseDuration( int duration )
- { progressAnimation().data()->setDuration( duration ); }
-
- //! return 'hover' rect position when widget is animated
- virtual const QRect& animatedRect( void ) const
- { return _animatedRect; }
-
- //! current rect
- virtual const QRect& currentRect( void ) const
- { return _currentRect; }
-
- //! timer
- const QBasicTimer& timer( void ) const
- { return _timer; }
-
- //! animation opacity
- virtual qreal opacity( void ) const
- { return _opacity; }
-
- //! animation opacity
- virtual void setOpacity( qreal value )
- {
- value = digitize( value );
- if( _opacity == value ) return;
- _opacity = value;
- setDirty();
- }
-
- //! animation progress
- virtual qreal progress( void ) const
- { return _progress; }
-
- //! animation progress
- virtual void setProgress( qreal value )
- {
- value = digitize( value );
- if( _progress == value ) return;
- _progress = value;
- updateAnimatedRect();
- }
-
- protected slots:
-
- //! updated animated rect
- virtual void updateAnimatedRect( void );
-
- protected:
-
- //! timer event
- virtual void timerEvent( QTimerEvent *);
-
- //!@name current object handling
- //@{
-
- //! object pointer
- /*! there is no need to guard it because the object contents is never accessed */
- typedef const QObject* ObjectPointer;
-
- //! current object
- virtual const ObjectPointer& currentObject( void ) const
- { return _currentObject; }
-
- //! current object
- virtual void setCurrentObject( const QObject* object )
- { _currentObject = ObjectPointer( object ); }
-
- //! current object
- virtual void clearCurrentObject( void )
- { _currentObject = NULL; }
-
- //@}
-
- //!@name rect handling
- //@{
-
- //! current rect
- virtual void setCurrentRect( const QRect& rect )
- { _currentRect = rect; }
-
- //! current rect
- virtual void clearCurrentRect( void )
- { _currentRect = QRect(); }
-
- //! previous rect
- virtual const QRect& previousRect( void ) const
- { return _previousRect; }
-
- //! previous rect
- virtual void setPreviousRect( const QRect& rect )
- { _previousRect = rect; }
-
- //! previous rect
- virtual void clearPreviousRect( void )
- { _previousRect = QRect(); }
-
- //! animated rect
- virtual void clearAnimatedRect( void )
- { _animatedRect = QRect(); }
-
- //@}
-
- //! toolbar enterEvent
- virtual void enterEvent( const QObject* );
-
- //! toolbar enterEvent
- virtual void leaveEvent( const QObject* );
-
- //! toolbutton added
- virtual void childAddedEvent( QObject* );
-
- //! toolbutton enter event
- virtual void childEnterEvent( const QObject* );
-
- private:
-
- //! fade animation
- Animation::Pointer _animation;
-
- //! progress animation
- Animation::Pointer _progressAnimation;
-
- //! opacity
- qreal _opacity;
-
- //! opacity
- qreal _progress;
-
- //! timer
- /*! this allows to add some delay before starting leaveEvent animation */
- QBasicTimer _timer;
-
- //! current object
- ObjectPointer _currentObject;
-
- //! current rect
- QRect _currentRect;
-
- //! previous rect
- QRect _previousRect;
-
- //! animated rect
- QRect _animatedRect;
-
- //! true if toolbar was entered at least once (this prevents some initialization glitches)
- bool _entered;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygentoolbarengine.cpp
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygentoolbarengine.h"
-#include "oxygentoolbarengine.moc"
-
-#include <QtCore/QEvent>
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- void ToolBarEngine::registerWidget( QWidget* widget )
- {
-
- if( !widget ) return;
-
- // create new data class
- if( !_data.contains( widget ) )
- {
- DataMap<ToolBarData>::Value value( new ToolBarData( this, widget, duration() ) );
- value.data()->setFollowMouseDuration( followMouseDuration() );
- _data.insert( widget, value, enabled() );
- }
-
- // connect destruction signal
- disconnect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)) );
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)) );
-
- }
-
- //____________________________________________________________
- BaseEngine::WidgetList ToolBarEngine::registeredWidgets( void ) const
- {
- WidgetList out;
-
- // the typedef is needed to make Krazy happy
- typedef DataMap<ToolBarData>::Value Value;
- foreach( const Value& value, _data )
- { if( value ) out.insert( value.data()->target().data() ); }
- return out;
- }
-
- //____________________________________________________________
- bool ToolBarEngine::isAnimated( const QObject* object )
- {
- if( !enabled() ) return false;
-
- DataMap<ToolBarData>::Value data( _data.find( object ) );
- if( !data ) return false;
- if( Animation::Pointer animation = data.data()->animation() ) return animation.data()->isRunning();
- else return false;
- }
-
- //____________________________________________________________
- bool ToolBarEngine::isFollowMouseAnimated( const QObject* object )
- {
- if( !enabled() ) return false;
-
- DataMap<ToolBarData>::Value data( _data.find( object ) );
- if( !data ) return false;
- if( Animation::Pointer animation = data.data()->progressAnimation() ) return animation.data()->isRunning();
- else return false;
- }
-
- //____________________________________________________________
- QRect ToolBarEngine::currentRect( const QObject* object )
- {
- if( !enabled() ) return QRect();
- DataMap<ToolBarData>::Value data( _data.find( object ) );
- return data ? data.data()->currentRect():QRect();
- }
-
- //____________________________________________________________
- QRect ToolBarEngine::animatedRect( const QObject* object )
- {
- if( !enabled() ) return QRect();
- DataMap<ToolBarData>::Value data( _data.find( object ) );
- return data ? data.data()->animatedRect():QRect();
- }
-
- //____________________________________________________________
- bool ToolBarEngine::isTimerActive( const QObject* object )
- {
- if( !enabled() ) return false;
- DataMap<ToolBarData>::Value data( _data.find( object ) );
- return data ? data.data()->timer().isActive():false;
- }
-
-}
+++ /dev/null
-#ifndef oxygentoolbarengine_h
-#define oxygentoolbarengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygentoolbarengine.h
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygentoolbardata.h"
-
-namespace Oxygen
-{
-
- //! follow-mouse toolbar animation
- class ToolBarEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit ToolBarEngine( QObject* parent ):
- BaseEngine( parent ),
- _followMouseDuration( 150 )
- {}
-
- //! destructor
- virtual ~ToolBarEngine( void )
- {}
-
- //! register toolbar
- virtual void registerWidget( QWidget* );
-
- //! returns registered widgets
- virtual WidgetList registeredWidgets( void ) const;
-
- //! return true if object is animated
- virtual bool isAnimated( const QObject* );
-
- //! return true if object is animated
- virtual bool isFollowMouseAnimated( const QObject* );
-
- //! animation opacity
- virtual qreal opacity( const QObject* object )
- { return isAnimated( object ) ? _data.find( object ).data()->opacity(): AnimationData::OpacityInvalid; }
-
- //! return 'hover' rect position when widget is animated
- virtual QRect currentRect( const QObject* );
-
- //! return 'hover' rect position when widget is animated
- virtual QRect animatedRect( const QObject* );
-
- //! timer
- virtual bool isTimerActive( const QObject* );
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- //! duration
- virtual int followMouseDuration( void ) const
- { return _followMouseDuration; }
-
- //! duration
- virtual void setFollowMouseDuration( int duration )
- {
- _followMouseDuration = duration;
- foreach( const DataMap<ToolBarData>::Value& value, _data )
- { if( value ) value.data()->setFollowMouseDuration( duration ); }
- }
-
- protected slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! follow mouse animation duration
- int _followMouseDuration;
-
- //! data map
- DataMap<ToolBarData> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygentoolboxengine.h
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-
-#include "oxygentoolboxengine.h"
-#include "oxygentoolboxengine.moc"
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- bool ToolBoxEngine::registerWidget( QWidget* widget )
- {
-
- if( !widget ) return false;
- if( !_data.contains( widget ) ) { _data.insert( widget, new WidgetStateData( this, widget, duration() ), enabled() ); }
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
- return true;
-
- }
-
- //____________________________________________________________
- bool ToolBoxEngine::updateState( const QPaintDevice* object, bool value )
- {
- PaintDeviceDataMap<WidgetStateData>::Value data( ToolBoxEngine::data( object ) );
- return ( data && data.data()->updateState( value ) );
- }
-
- //____________________________________________________________
- bool ToolBoxEngine::isAnimated( const QPaintDevice* object )
- {
-
- PaintDeviceDataMap<WidgetStateData>::Value data( ToolBoxEngine::data( object ) );
- return ( data && data.data()->animation() && data.data()->animation().data()->isRunning() );
-
- }
-
-}
+++ /dev/null
-#ifndef oxygentoolboxengine_h
-#define oxygentoolboxengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygentoolboxengine.h
-// QToolBox engine
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygenwidgetstatedata.h"
-
-namespace Oxygen
-{
-
- //! QToolBox animation engine
- class ToolBoxEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit ToolBoxEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~ToolBoxEngine( void )
- {}
-
- //! enability
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- //! register widget
- virtual bool registerWidget( QWidget* );
-
- //! true if widget hover state is changed
- virtual bool updateState( const QPaintDevice*, bool );
-
- //! true if widget is animated
- virtual bool isAnimated( const QPaintDevice* );
-
- //! animation opacity
- virtual qreal opacity( const QPaintDevice* object )
- { return isAnimated( object ) ? data( object ).data()->opacity(): AnimationData::OpacityInvalid; }
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* data )
- {
-
- if( !data ) return false;
-
- // reinterpret_cast is safe here since only the address is used to find
- // data in the map
- return _data.unregisterWidget( reinterpret_cast<QPaintDevice*>(data) );
-
- }
-
- protected:
-
- //! returns data associated to widget
- PaintDeviceDataMap<WidgetStateData>::Value data( const QPaintDevice* object )
- { return _data.find( object ).data(); }
-
- private:
-
- //! engine enability
- bool _enabled;
-
- //! animation duration
- int _duration;
-
- //! map
- PaintDeviceDataMap<WidgetStateData> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenwidgetstatedata.cpp
-// generic data container for widget widgetstate (mouse-over) animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenwidgetstatedata.h"
-#include "oxygenwidgetstatedata.moc"
-
-namespace Oxygen
-{
-
- //______________________________________________
- bool WidgetStateData::updateState( bool value )
- {
- if( _state == value ) return false;
- else {
-
- _state = value;
- animation().data()->setDirection( _state ? Animation::Forward : Animation::Backward );
- if( !animation().data()->isRunning() ) animation().data()->start();
- return true;
-
- }
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenwidgetstatedata_h
-#define oxygenwidgetstatedata_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenwidgetstatedata.h
-// generic data container for widgetstate hover (mouse-over) animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygengenericdata.h"
-
-namespace Oxygen
-{
-
- //! handle widget state (hover/focus/enable) changes
- class WidgetStateData: public GenericData
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- WidgetStateData( QObject* parent, QWidget* target, int duration, bool state = false ):
- GenericData( parent, target, duration ),
- _state( state )
- {}
-
- //! destructor
- virtual ~WidgetStateData( void )
- {}
-
- /*!
- returns true if hover has Changed
- and starts timer accordingly
- */
- virtual bool updateState( bool value );
-
- private:
-
- bool _state;
-
- };
-
-}
-
-#endif
+++ /dev/null
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenwidgetstateengine.h
-// stores event filters and maps widgets to timelines for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenwidgetstateengine.h"
-#include "oxygenwidgetstateengine.moc"
-
-#include "oxygenenabledata.h"
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- bool WidgetStateEngine::registerWidget( QWidget* widget, AnimationModes mode )
- {
-
- if( !widget ) return false;
- if( mode&AnimationHover && !_hoverData.contains( widget ) ) { _hoverData.insert( widget, new WidgetStateData( this, widget, duration() ), enabled() ); }
- if( mode&AnimationFocus && !_focusData.contains( widget ) ) { _focusData.insert( widget, new WidgetStateData( this, widget, duration() ), enabled() ); }
- if( mode&AnimationEnable && !_enableData.contains( widget ) ) { _enableData.insert( widget, new EnableData( this, widget, duration() ), enabled() ); }
-
- // connect destruction signal
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)), Qt::UniqueConnection );
-
- return true;
-
- }
-
- //____________________________________________________________
- BaseEngine::WidgetList WidgetStateEngine::registeredWidgets( AnimationModes mode ) const
- {
-
- WidgetList out;
-
- // the typedef is needed to make Krazy happy
- typedef DataMap<WidgetStateData>::Value Value;
-
- if( mode&AnimationHover )
- {
- foreach( const Value& value, _hoverData )
- { if( value ) out.insert( value.data()->target().data() ); }
- }
-
- if( mode&AnimationFocus )
- {
- foreach( const Value& value, _focusData )
- { if( value ) out.insert( value.data()->target().data() ); }
- }
-
- if( mode&AnimationEnable )
- {
- foreach( const Value& value, _enableData )
- { if( value ) out.insert( value.data()->target().data() ); }
- }
-
- return out;
-
- }
-
- //____________________________________________________________
- bool WidgetStateEngine::updateState( const QObject* object, AnimationMode mode, bool value )
- {
- DataMap<WidgetStateData>::Value data( WidgetStateEngine::data( object, mode ) );
- return ( data && data.data()->updateState( value ) );
- }
-
- //____________________________________________________________
- bool WidgetStateEngine::isAnimated( const QObject* object, AnimationMode mode )
- {
-
- DataMap<WidgetStateData>::Value data( WidgetStateEngine::data( object, mode ) );
- return ( data && data.data()->animation() && data.data()->animation().data()->isRunning() );
-
- }
-
- //____________________________________________________________
- DataMap<WidgetStateData>::Value WidgetStateEngine::data( const QObject* object, AnimationMode mode )
- {
-
- switch( mode )
- {
- case AnimationHover: return _hoverData.find( object ).data();
- case AnimationFocus: return _focusData.find( object ).data();
- case AnimationEnable: return _enableData.find( object ).data();
- default: return DataMap<WidgetStateData>::Value();
- }
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenwidgetstateengine_h
-#define oxygenwidgetstateengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenwidgetstateengine.h
-// stores event filters and maps widgets to animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygenwidgetstatedata.h"
-#include "oxygenanimationmodes.h"
-
-namespace Oxygen
-{
-
- //! used for simple widgets
- class WidgetStateEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit WidgetStateEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~WidgetStateEngine( void )
- {}
-
- //! register widget
- virtual bool registerWidget( QWidget*, AnimationModes );
-
- //! returns registered widgets
- virtual WidgetList registeredWidgets( AnimationModes ) const;
-
- using BaseEngine::registeredWidgets;
-
- //! true if widget hover state is changed
- virtual bool updateState( const QObject*, AnimationMode, bool );
-
- //! true if widget is animated
- virtual bool isAnimated( const QObject*, AnimationMode );
-
- //! animation opacity
- virtual qreal opacity( const QObject* object, AnimationMode mode )
- { return isAnimated( object, mode ) ? data( object, mode ).data()->opacity(): AnimationData::OpacityInvalid; }
-
- //! duration
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _hoverData.setEnabled( value );
- _focusData.setEnabled( value );
- _enableData.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _hoverData.setDuration( value );
- _focusData.setDuration( value );
- _enableData.setDuration( value );
- }
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- {
- if( !object ) return false;
- bool found = false;
- if( _hoverData.unregisterWidget( object ) ) found = true;
- if( _focusData.unregisterWidget( object ) ) found = true;
- if( _enableData.unregisterWidget( object ) ) found = true;
- return found;
- }
-
- protected:
-
- //! returns data associated to widget
- DataMap<WidgetStateData>::Value data( const QObject*, AnimationMode );
-
- private:
-
- //! maps
- DataMap<WidgetStateData> _hoverData;
- DataMap<WidgetStateData> _focusData;
- DataMap<WidgetStateData> _enableData;
-
- };
-
-}
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(Oxygen::AnimationModes)
-
-#endif
########### next target ###############
set(kstyle_oxygen_config_PART_SRCS
- oxygenanimationconfigwidget.cpp
- oxygenfollowmouseanimationconfigitem.cpp
oxygenstyleconfig.cpp
)
kde4_add_kcfg_files(kstyle_oxygen_config_PART_SRCS ../oxygenstyleconfigdata.kcfgc)
kde4_add_ui_files(kstyle_oxygen_config_PART_SRCS
- ui/oxygenfollowmouseanimationconfigbox.ui
ui/oxygenstyleconfig.ui
)
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenanimationconfigwidget.cpp
-// animation configuration widget
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimationconfigwidget.h"
-#include "oxygenanimationconfigwidget.moc"
-#include "oxygenanimationconfigitem.h"
-#include "oxygenfollowmouseanimationconfigitem.h"
-#include "oxygengenericanimationconfigitem.h"
-#include "oxygenstyleconfigdata.h"
-
-#include <QtGui/QButtonGroup>
-#include <QtGui/QHoverEvent>
-#include <QtCore/QTextStream>
-#include <KLocale>
-
-namespace Oxygen
-{
-
- //_______________________________________________
- AnimationConfigWidget::AnimationConfigWidget( QWidget* parent ):
- BaseAnimationConfigWidget( parent )
- {
-
- QGridLayout* layout( qobject_cast<QGridLayout*>( BaseAnimationConfigWidget::layout() ) );
-
- setupItem( layout, _genericAnimations = new GenericAnimationConfigItem( this,
- i18n("Focus, mouseover and widget state transition"),
- i18n("Configure widgets' focus and mouseover highlight animation, as well as widget enabled/disabled state transition") ) );
-
- setupItem( layout, _toolBarAnimations = new FollowMouseAnimationConfigItem( this,
- i18n("Toolbar highlight" ),
- i18n("Configure toolbars' mouseover highlight animation" ) ) );
- _toolBarAnimations->hideDurationSpinBox();
-
- setupItem( layout, _menuBarAnimations = new FollowMouseAnimationConfigItem( this,
- i18n("Menu bar highlight" ),
- i18n("Configure menu bars' mouseover highlight animation" ) ) );
-
- setupItem( layout, _menuAnimations = new FollowMouseAnimationConfigItem( this,
- i18n("Menu highlight" ),
- i18n("Configure menus' mouseover highlight animation" ) ) );
-
- setupItem( layout, _progressBarAnimations = new GenericAnimationConfigItem( this,
- i18n( "Progress bar animation" ),
- i18n( "Configure progress bars' steps animation" ) ) );
-
- setupItem( layout, _stackedWidgetAnimations = new GenericAnimationConfigItem( this,
- i18n( "Tab transitions" ), i18n( "Configure fading transition between tabs" ) ) );
-
- setupItem( layout, _labelAnimations = new GenericAnimationConfigItem( this,
- i18n( "Label transitions" ), i18n( "Configure fading transition when a label's text is changed" ) ) );
-
- setupItem( layout, _lineEditAnimations = new GenericAnimationConfigItem( this,
- i18n( "Text editor transitions" ), i18n( "Configure fading transition when an editor's text is changed" ) ) );
-
- setupItem( layout, _comboBoxAnimations = new GenericAnimationConfigItem( this,
- i18n( "Combo box transitions" ), i18n( "Configure fading transition when a combo box's selected choice is changed" ) ) );
-
- // add a separator
- QFrame* frame = new QFrame( this );
- frame->setFrameStyle( QFrame::HLine|QFrame::Sunken );
- layout->addWidget( frame, _row, 0, 1, 2 );
- ++_row;
-
- // progress bar busy animation
- setupItem( layout, _progressBarBusyAnimations = new GenericAnimationConfigItem( this,
- i18n( "Busy indicator steps" ),
- i18n( "Configure progress bars' busy indicator animation" ) ) );
-
- // add spacers to the first column, previous row to finalize layout
- layout->addItem( new QSpacerItem( 25, 0 ), _row-1, 0, 1, 1 );
-
- // add vertical spacer
- layout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ), _row, 1, 1, 1 );
- ++_row;
-
- connect( animationsEnabled(), SIGNAL(toggled(bool)), SLOT(updateChanged()) );
- foreach( AnimationConfigItem* item, findChildren<AnimationConfigItem*>() )
- {
- if( item != _progressBarBusyAnimations )
- {
- item->QWidget::setEnabled( false );
- connect( animationsEnabled(), SIGNAL(toggled(bool)), item, SLOT(setEnabled(bool)) );
- }
- }
-
- }
-
- //_______________________________________________
- AnimationConfigWidget::~AnimationConfigWidget( void )
- {}
-
- //_______________________________________________
- void AnimationConfigWidget::load( void )
- {
-
- animationsEnabled()->setChecked( StyleConfigData::animationsEnabled() );
- _genericAnimations->setEnabled( StyleConfigData::genericAnimationsEnabled() );
- _genericAnimations->setDuration( StyleConfigData::genericAnimationsDuration() );
-
- _toolBarAnimations->setEnabled( StyleConfigData::toolBarAnimationType() != StyleConfigData::TB_NONE );
- _toolBarAnimations->setDuration( StyleConfigData::genericAnimationsDuration() );
- _toolBarAnimations->setFollowMouseDuration( StyleConfigData::toolBarAnimationsDuration() );
-
- switch( StyleConfigData::toolBarAnimationType() )
- {
- case StyleConfigData::TB_FOLLOW_MOUSE:
- _toolBarAnimations->setType( 1 );
- break;
-
- case StyleConfigData::TB_FADE:
- default:
- _toolBarAnimations->setType( 0 );
- break;
- }
-
- _menuBarAnimations->setEnabled( StyleConfigData::menuBarAnimationType() != StyleConfigData::MB_NONE );
- _menuBarAnimations->setDuration( StyleConfigData::menuBarAnimationsDuration() );
- _menuBarAnimations->setFollowMouseDuration( StyleConfigData::menuBarFollowMouseAnimationsDuration() );
- switch( StyleConfigData::menuBarAnimationType() )
- {
- case StyleConfigData::MB_FOLLOW_MOUSE:
- _menuBarAnimations->setType( 1 );
- break;
-
- case StyleConfigData::MB_FADE:
- default:
- _menuBarAnimations->setType( 0 );
- break;
- }
-
- _menuAnimations->setEnabled( StyleConfigData::menuAnimationType() != StyleConfigData::ME_NONE );
- _menuAnimations->setDuration( StyleConfigData::menuAnimationsDuration() );
- _menuAnimations->setFollowMouseDuration( StyleConfigData::menuFollowMouseAnimationsDuration() );
- switch( StyleConfigData::menuAnimationType() )
- {
- case StyleConfigData::ME_FOLLOW_MOUSE:
- _menuAnimations->setType( 1 );
- break;
-
- case StyleConfigData::ME_FADE:
- default:
- _menuAnimations->setType( 0 );
- break;
- }
-
- _progressBarAnimations->setEnabled( StyleConfigData::progressBarAnimationsEnabled() );
- _progressBarAnimations->setDuration( StyleConfigData::progressBarAnimationsDuration() );
-
- _progressBarBusyAnimations->setEnabled( StyleConfigData::progressBarAnimated() );
- _progressBarBusyAnimations->setDuration( StyleConfigData::progressBarBusyStepDuration() );
-
- _stackedWidgetAnimations->setEnabled( StyleConfigData::stackedWidgetTransitionsEnabled() );
- _stackedWidgetAnimations->setDuration( StyleConfigData::stackedWidgetTransitionsDuration() );
-
- _labelAnimations->setEnabled( StyleConfigData::labelTransitionsEnabled() );
- _labelAnimations->setDuration( StyleConfigData::labelTransitionsDuration() );
-
- _lineEditAnimations->setEnabled( StyleConfigData::lineEditTransitionsEnabled() );
- _lineEditAnimations->setDuration( StyleConfigData::lineEditTransitionsDuration() );
-
- _comboBoxAnimations->setEnabled( StyleConfigData::comboBoxTransitionsEnabled() );
- _comboBoxAnimations->setDuration( StyleConfigData::comboBoxTransitionsDuration() );
- }
-
- //_______________________________________________
- void AnimationConfigWidget::save( void )
- {
-
- StyleConfigData::setAnimationsEnabled( animationsEnabled()->isChecked() );
- StyleConfigData::setGenericAnimationsEnabled( _genericAnimations->enabled() );
- StyleConfigData::setGenericAnimationsDuration( _genericAnimations->duration() );
-
- StyleConfigData::setToolBarAnimationsDuration( _toolBarAnimations->followMouseDuration() );
- if( !_toolBarAnimations->enabled() ) StyleConfigData::setToolBarAnimationType( StyleConfigData::TB_NONE );
- else if( _toolBarAnimations->type() == 1 ) StyleConfigData::setToolBarAnimationType( StyleConfigData::TB_FOLLOW_MOUSE );
- else StyleConfigData::setToolBarAnimationType( StyleConfigData::TB_FADE );
-
- StyleConfigData::setMenuBarAnimationsDuration( _menuBarAnimations->duration() );
- StyleConfigData::setMenuBarFollowMouseAnimationsDuration( _menuBarAnimations->followMouseDuration() );
- if( !_menuBarAnimations->enabled() ) StyleConfigData::setMenuBarAnimationType( StyleConfigData::MB_NONE );
- else if( _menuBarAnimations->type() == 1 ) StyleConfigData::setMenuBarAnimationType( StyleConfigData::MB_FOLLOW_MOUSE );
- else StyleConfigData::setMenuBarAnimationType( StyleConfigData::MB_FADE );
-
- StyleConfigData::setMenuAnimationsDuration( _menuAnimations->duration() );
- StyleConfigData::setMenuFollowMouseAnimationsDuration( _menuAnimations->followMouseDuration() );
- if( !_menuAnimations->enabled() ) StyleConfigData::setMenuAnimationType( StyleConfigData::ME_NONE );
- else if( _menuAnimations->type() == 1 ) StyleConfigData::setMenuAnimationType( StyleConfigData::ME_FOLLOW_MOUSE );
- else StyleConfigData::setMenuAnimationType( StyleConfigData::ME_FADE );
-
- StyleConfigData::setProgressBarAnimationsEnabled( _progressBarAnimations->enabled() );
- StyleConfigData::setProgressBarAnimationsDuration( _progressBarAnimations->duration() );
-
- StyleConfigData::setProgressBarAnimated( _progressBarBusyAnimations->enabled() );
- StyleConfigData::setProgressBarBusyStepDuration( _progressBarBusyAnimations->duration() );
-
- StyleConfigData::setStackedWidgetTransitionsEnabled( _stackedWidgetAnimations->enabled() );
- StyleConfigData::setStackedWidgetTransitionsDuration( _stackedWidgetAnimations->duration() );
-
- StyleConfigData::setLabelTransitionsEnabled( _labelAnimations->enabled() );
- StyleConfigData::setLabelTransitionsDuration( _labelAnimations->duration() );
-
- StyleConfigData::setLineEditTransitionsEnabled( _lineEditAnimations->enabled() );
- StyleConfigData::setLineEditTransitionsDuration( _lineEditAnimations->duration() );
-
- StyleConfigData::setComboBoxTransitionsEnabled( _comboBoxAnimations->enabled() );
- StyleConfigData::setComboBoxTransitionsDuration( _comboBoxAnimations->duration() );
- setChanged( false );
-
- }
-
- //_______________________________________________
- void AnimationConfigWidget::updateChanged( void )
- {
-
- bool modified( false );
- if( animationsEnabled()->isChecked() != StyleConfigData::animationsEnabled() ) modified = true;
- else if( _genericAnimations->enabled() != StyleConfigData::genericAnimationsEnabled() ) modified = true;
- else if( _genericAnimations->duration() != StyleConfigData::genericAnimationsDuration() ) modified = true;
-
- else if( _toolBarAnimations->duration() != StyleConfigData::genericAnimationsDuration() ) modified = true;
- else if( _toolBarAnimations->followMouseDuration() != StyleConfigData::toolBarAnimationsDuration() ) modified = true;
- else if( StyleConfigData::toolBarAnimationType() == StyleConfigData::TB_NONE && _toolBarAnimations->enabled() ) modified = true;
- else if( StyleConfigData::toolBarAnimationType() == StyleConfigData::TB_FOLLOW_MOUSE && !( _toolBarAnimations->type() == 1 && _toolBarAnimations->enabled() ) ) modified = true;
- else if( StyleConfigData::toolBarAnimationType() == StyleConfigData::TB_FADE && !( _toolBarAnimations->type() == 0 && _toolBarAnimations->enabled() )) modified = true;
-
- else if( _menuBarAnimations->duration() != StyleConfigData::menuBarAnimationsDuration() ) modified = true;
- else if( _menuBarAnimations->followMouseDuration() != StyleConfigData::menuBarFollowMouseAnimationsDuration() ) modified = true;
- else if( StyleConfigData::menuBarAnimationType() == StyleConfigData::MB_NONE && _menuBarAnimations->enabled() ) modified = true;
- else if( StyleConfigData::menuBarAnimationType() == StyleConfigData::MB_FOLLOW_MOUSE && !( _menuBarAnimations->type() == 1 && _menuBarAnimations->enabled() ) ) modified = true;
- else if( StyleConfigData::menuBarAnimationType() == StyleConfigData::MB_FADE && !( _menuBarAnimations->type() == 0 && _menuBarAnimations->enabled() ) ) modified = true;
-
- else if( _menuAnimations->duration() != StyleConfigData::menuAnimationsDuration() ) modified = true;
- else if( _menuAnimations->followMouseDuration() != StyleConfigData::menuFollowMouseAnimationsDuration() ) modified = true;
- else if( StyleConfigData::menuAnimationType() == StyleConfigData::ME_NONE && _menuAnimations->enabled() ) modified = true;
- else if( StyleConfigData::menuAnimationType() == StyleConfigData::ME_FOLLOW_MOUSE && !( _menuAnimations->type() == 1 && _menuAnimations->enabled() ) ) modified = true;
- else if( StyleConfigData::menuAnimationType() == StyleConfigData::ME_FADE && !( _menuAnimations->type() == 0 && _menuAnimations->enabled() ) ) modified = true;
-
- else if( _progressBarAnimations->enabled() != StyleConfigData::progressBarAnimationsEnabled() ) modified = true;
- else if( _progressBarAnimations->duration() != StyleConfigData::progressBarAnimationsDuration() ) modified = true;
-
- else if( _progressBarBusyAnimations->enabled() != StyleConfigData::progressBarAnimated() ) modified = true;
- else if( _progressBarBusyAnimations->duration() != StyleConfigData::progressBarBusyStepDuration() ) modified = true;
-
- else if( _stackedWidgetAnimations->enabled() != StyleConfigData::stackedWidgetTransitionsEnabled() ) modified = true;
- else if( _stackedWidgetAnimations->duration() != StyleConfigData::stackedWidgetTransitionsDuration() ) modified = true;
-
- else if( _labelAnimations->enabled() != StyleConfigData::labelTransitionsEnabled() ) modified = true;
- else if( _labelAnimations->duration() != StyleConfigData::labelTransitionsDuration() ) modified = true;
-
- else if( _lineEditAnimations->enabled() != StyleConfigData::lineEditTransitionsEnabled() ) modified = true;
- else if( _lineEditAnimations->duration() != StyleConfigData::lineEditTransitionsDuration() ) modified = true;
-
- else if( _comboBoxAnimations->enabled() != StyleConfigData::comboBoxTransitionsEnabled() ) modified = true;
- else if( _comboBoxAnimations->duration() != StyleConfigData::comboBoxTransitionsDuration() ) modified = true;
-
- setChanged( modified );
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenanimationconfigwidget_h
-#define oxygenanimationconfigwidget_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenanimationconfigwidget.h
-// animation configuration item
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseanimationconfigwidget.h"
-
-namespace Oxygen
-{
- class GenericAnimationConfigItem;
- class FollowMouseAnimationConfigItem;
-
- class AnimationConfigWidget: public BaseAnimationConfigWidget
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit AnimationConfigWidget( QWidget* = 0 );
-
- //! destructor
- virtual ~AnimationConfigWidget( void );
-
- public slots:
-
- //! read current configuration
- virtual void load( void );
-
- //! save current configuration
- virtual void save( void );
-
- protected slots:
-
- //! check whether configuration is changed and emit appropriate signal if yes
- virtual void updateChanged();
-
- private:
-
- GenericAnimationConfigItem* _genericAnimations;
- GenericAnimationConfigItem* _progressBarAnimations;
- GenericAnimationConfigItem* _progressBarBusyAnimations;
- GenericAnimationConfigItem* _stackedWidgetAnimations;
- GenericAnimationConfigItem* _labelAnimations;
- GenericAnimationConfigItem* _lineEditAnimations;
- GenericAnimationConfigItem* _comboBoxAnimations;
- FollowMouseAnimationConfigItem* _toolBarAnimations;
- FollowMouseAnimationConfigItem* _menuBarAnimations;
- FollowMouseAnimationConfigItem* _menuAnimations;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenfollowmouseanimationconfigitem.cpp
-// animation configuration item
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenfollowmouseanimationconfigitem.h"
-#include "oxygenfollowmouseanimationconfigitem.moc"
-#include "ui_oxygenfollowmouseanimationconfigbox.h"
-
-namespace Oxygen
-{
-
- //_______________________________________________
- FollowMouseAnimationConfigBox::FollowMouseAnimationConfigBox(QWidget* parent):
- QFrame( parent ),
- ui( new Ui_FollowMouseAnimationConfigBox() )
- {
- ui->setupUi( this );
- ui->followMouseDurationSpinBox->setEnabled( false );
- connect( ui->typeComboBox, SIGNAL(currentIndexChanged(int)), SLOT(typeChanged(int)) );
- }
-
- //_______________________________________________
- FollowMouseAnimationConfigBox::~FollowMouseAnimationConfigBox( void )
- { delete ui; }
-
- //_______________________________________________
- KComboBox* FollowMouseAnimationConfigBox::typeComboBox( void ) const
- { return ui->typeComboBox; }
-
- //_______________________________________________
- QSpinBox* FollowMouseAnimationConfigBox::durationSpinBox( void ) const
- { return ui->durationSpinBox; }
-
- //_______________________________________________
- QLabel* FollowMouseAnimationConfigBox::durationLabel( void ) const
- { return ui->durationLabel; }
-
- //_______________________________________________
- QSpinBox* FollowMouseAnimationConfigBox::followMouseDurationSpinBox( void ) const
- { return ui->followMouseDurationSpinBox; }
-
- //_______________________________________________
- void FollowMouseAnimationConfigBox::typeChanged( int value )
- {
- ui->followMouseDurationLabel->setEnabled( value == 1 );
- ui->followMouseDurationSpinBox->setEnabled( value == 1 );
- }
-
- //_______________________________________________
- void FollowMouseAnimationConfigItem::initializeConfigurationWidget( QWidget* parent )
- {
- assert( !_configurationWidget );
- _configurationWidget = new FollowMouseAnimationConfigBox( parent );
- setConfigurationWidget( _configurationWidget.data() );
-
- connect( _configurationWidget.data()->typeComboBox(), SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
- connect( _configurationWidget.data()->durationSpinBox(), SIGNAL(valueChanged(int)), SIGNAL(changed()) );
- connect( _configurationWidget.data()->followMouseDurationSpinBox(), SIGNAL(valueChanged(int)), SIGNAL(changed()) );
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenfollowmouseanimationconfigitem_h
-#define oxygenfollowmouseanimationconfigitem_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenanimationconfigitem.h
-// animation configuration item
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimationconfigitem.h"
-
-#include <KComboBox>
-
-#include <QtCore/QWeakPointer>
-#include <QtGui/QFrame>
-#include <QtGui/QLabel>
-#include <QtGui/QSpinBox>
-
-class Ui_FollowMouseAnimationConfigBox;
-
-namespace Oxygen
-{
-
- class FollowMouseAnimationConfigBox: public QFrame
- {
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit FollowMouseAnimationConfigBox(QWidget*);
-
- //! destructor
- virtual ~FollowMouseAnimationConfigBox( void );
-
- //! type ComboBox
- KComboBox* typeComboBox( void ) const;
-
- //! duration spin box
- QSpinBox* durationSpinBox( void ) const;
-
- //! duration spin box
- QLabel* durationLabel( void ) const;
-
- //! follow mouse duration spinbox
- QSpinBox* followMouseDurationSpinBox( void ) const;
-
- protected slots:
-
- //! type changed
- void typeChanged( int );
-
- private:
-
- Ui_FollowMouseAnimationConfigBox* ui;
-
- };
-
- //! generic animation config item
- class FollowMouseAnimationConfigItem: public AnimationConfigItem
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit FollowMouseAnimationConfigItem( QWidget* parent, const QString& title = QString(), const QString& description = QString() ):
- AnimationConfigItem( parent, title, description )
- {}
-
- //! initialize configuration widget
- virtual void initializeConfigurationWidget( QWidget* );
-
- //! configuration widget
- virtual QWidget* configurationWidget( void ) const
- {
- assert( _configurationWidget );
- return _configurationWidget.data();
- }
-
- //! type
- virtual int type( void ) const
- { return (_configurationWidget) ? _configurationWidget.data()->typeComboBox()->currentIndex():0; }
-
- //! duration
- virtual int duration( void ) const
- { return (_configurationWidget) ? _configurationWidget.data()->durationSpinBox()->value():0; }
-
- //! duration
- virtual int followMouseDuration( void ) const
- { return (_configurationWidget) ? _configurationWidget.data()->followMouseDurationSpinBox()->value():0; }
-
- //! hide duration spinbox
- virtual void hideDurationSpinBox( void )
- {
- if( _configurationWidget )
- {
- _configurationWidget.data()->durationLabel()->hide();
- _configurationWidget.data()->durationSpinBox()->hide();
- }
- }
-
- public slots:
-
- //! type
- virtual void setType( int value )
- {
- if( _configurationWidget )
- { _configurationWidget.data()->typeComboBox()->setCurrentIndex( value ); }
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- if( _configurationWidget )
- { _configurationWidget.data()->durationSpinBox()->setValue( value ); }
- }
-
- //! follow mouse duration
- virtual void setFollowMouseDuration( int value )
- {
- if( _configurationWidget )
- { _configurationWidget.data()->followMouseDurationSpinBox()->setValue( value ); }
- }
-
- private:
-
- //! configuration widget
- QWeakPointer<FollowMouseAnimationConfigBox> _configurationWidget;
-
- };
-
-}
-
-#endif
#include "oxygenstyleconfig.h"
#include "oxygenstyleconfig.moc"
-#include "oxygenanimationconfigwidget.h"
#include "oxygenstyleconfigdata.h"
#include <QtCore/QTextStream>
namespace Oxygen
{
-
//__________________________________________________________________
StyleConfig::StyleConfig(QWidget* parent):
- QWidget(parent),
- _expertMode( false ),
- _animationConfigWidget(0)
+ QWidget(parent)
{
KGlobal::locale()->insertCatalog("kstyle_config");
// connections
connect( _windowDragMode, SIGNAL(currentIndexChanged(int)), SLOT(windowDragModeChanged(int)) );
- connect( _expertModeButton, SIGNAL(pressed()), SLOT(toggleExpertModeInternal()) );
-
- _expertModeButton->setIcon( KIcon("configure") );
- // toggle expert mode
- toggleExpertModeInternal( false );
+ // updateMinimumSize();
// load setup from configData
load();
connect( _checkDrawX, SIGNAL(toggled(bool)), SLOT(updateChanged()) );
connect( _splitterProxyEnabled, SIGNAL(toggled(bool)), SLOT(updateChanged()) );
connect( _mnemonicsMode, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
- connect( _animationsEnabled, SIGNAL(toggled(bool)), SLOT(updateChanged()) );
connect( _cacheEnabled, SIGNAL(toggled(bool)), SLOT(updateChanged()) );
connect( _viewDrawTriangularExpander, SIGNAL(toggled(bool)), SLOT(updateChanged()) );
connect( _viewTriangularExpanderSize, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
StyleConfigData::setTabStyle( tabStyle() );
StyleConfigData::setViewTriangularExpanderSize( triangularExpanderSize() );
- if( _expertMode )
- {
-
- _animationConfigWidget->save();
-
- } else {
-
- StyleConfigData::setAnimationsEnabled( _animationsEnabled->isChecked() );
-
- }
-
StyleConfigData::setUseWMMoveResize( _useWMMoveResize->isChecked() );
if( _windowDragMode->currentIndex() == 0 )
{
}
//__________________________________________________________________
- void StyleConfig::toggleExpertMode( bool value )
- {
- _expertModeContainer->hide();
- toggleExpertModeInternal( value );
- }
-
- //__________________________________________________________________
- void StyleConfig::toggleExpertModeInternal( bool value )
- {
-
- // store value
- _expertMode = value;
-
- // update button text
- _expertModeButton->setText( _expertMode ? i18n( "Hide Advanced Configuration Options" ):i18n( "Show Advanced Configuration Options" ) );
-
- // update widget visibility based on expert mode
- if( _expertMode )
- {
-
- // create animationConfigWidget if needed
- if( !_animationConfigWidget )
- {
- _animationConfigWidget = new AnimationConfigWidget();
- _animationConfigWidget->installEventFilter( this );
- connect( _animationConfigWidget, SIGNAL(changed(bool)), SLOT(updateChanged()) );
- connect( _animationConfigWidget, SIGNAL(layoutChanged()), SLOT(updateLayout()) );
- _animationConfigWidget->load();
- }
-
- // add animationConfigWidget to tabbar if needed
- if( tabWidget->indexOf( _animationConfigWidget ) < 0 )
- { tabWidget->insertTab( 1, _animationConfigWidget, i18n( "Animations" ) ); }
-
- } else if( _animationConfigWidget ) {
-
- if( int index = tabWidget->indexOf( _animationConfigWidget ) >= 0 )
- { tabWidget->removeTab( index ); }
-
- }
-
- _mnemonicsLabel->setVisible( _expertMode );
- _mnemonicsMode->setVisible( _expertMode );
- _animationsEnabled->setVisible( !_expertMode );
- _cacheEnabled->setVisible( _expertMode );
- _useWMMoveResize->setVisible( _expertMode );
- _viewsExpertWidget->setVisible( _expertMode );
-
- updateMinimumSize();
-
- }
-
- //__________________________________________________________________
bool StyleConfig::eventFilter( QObject* object, QEvent* event )
{
//__________________________________________________________________
void StyleConfig::updateLayout( void )
{
- if( _animationConfigWidget )
- {
- const int delta = _animationConfigWidget->minimumSizeHint().height() - _animationConfigWidget->size().height();
- window()->setMinimumSize( QSize( window()->minimumSizeHint().width(), window()->size().height() + delta ) );
- }
}
//__________________________________________________________________
else if( (_checkDrawX->isChecked() ? StyleConfigData::CS_X : StyleConfigData::CS_CHECK) != StyleConfigData::checkBoxStyle() ) modified = true;
else if( menuMode() != StyleConfigData::menuHighlightMode() ) modified = true;
else if( tabStyle() != StyleConfigData::tabStyle() ) modified = true;
- else if( _animationsEnabled->isChecked() != StyleConfigData::animationsEnabled() ) modified = true;
else if( _cacheEnabled->isChecked() != StyleConfigData::cacheEnabled() ) modified = true;
else if( _useWMMoveResize->isChecked() != StyleConfigData::useWMMoveResize() ) modified = true;
else if( triangularExpanderSize() != StyleConfigData::viewTriangularExpanderSize() ) modified = true;
- else if( _animationConfigWidget && _animationConfigWidget->isChanged() ) modified = true;
if( !modified )
{
_tabStyleSingle->setChecked( StyleConfigData::tabStyle() == StyleConfigData::TS_SINGLE );
_tabStylePlain->setChecked( StyleConfigData::tabStyle() == StyleConfigData::TS_PLAIN );
- _animationsEnabled->setChecked( StyleConfigData::animationsEnabled() );
_cacheEnabled->setChecked( StyleConfigData::cacheEnabled() );
if( !StyleConfigData::windowDragEnabled() ) _windowDragMode->setCurrentIndex(0);
_useWMMoveResize->setChecked( StyleConfigData::useWMMoveResize() );
- // animation config widget
- if( _animationConfigWidget ) _animationConfigWidget->load();
-
}
//__________________________________________________________________
//! reset to saved configuration
void reset( void );
- //! toggle expert mode
- virtual void toggleExpertMode( bool );
-
protected Q_SLOTS:
//! update minimum size
//! update options enable state based on selected drag mode
void windowDragModeChanged( int );
- //! toggle expert mode
- virtual void toggleExpertModeInternal( void )
- { toggleExpertModeInternal( !_expertMode ); }
-
- //! toggle expert mode
- virtual void toggleExpertModeInternal( bool );
-
protected:
//! event processing
private:
- bool _expertMode;
-
- //! animation config (expert mode only)
- AnimationConfigWidget* _animationConfigWidget;
-
};
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>FollowMouseAnimationConfigBox</class>
- <widget class="QFrame" name="FollowMouseAnimationConfigBox">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>94</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="windowTitle">
- <string>Frame</string>
- </property>
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Sunken</enum>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Animation type:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>typeComboBox</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KComboBox" name="typeComboBox">
- <item>
- <property name="text">
- <string>Fade</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Follow Mouse</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="durationLabel">
- <property name="text">
- <string>Fade duration:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>durationSpinBox</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KIntSpinBox" name="durationSpinBox">
- <property name="suffix">
- <string>ms</string>
- </property>
- <property name="minimum">
- <number>5</number>
- </property>
- <property name="maximum">
- <number>2000</number>
- </property>
- <property name="singleStep">
- <number>5</number>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="followMouseDurationLabel">
- <property name="text">
- <string>Follow mouse duration:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>followMouseDurationSpinBox</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KIntSpinBox" name="followMouseDurationSpinBox">
- <property name="suffix">
- <string>ms</string>
- </property>
- <property name="minimum">
- <number>5</number>
- </property>
- <property name="maximum">
- <number>2000</number>
- </property>
- <property name="singleStep">
- <number>5</number>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KIntSpinBox</class>
- <extends>QSpinBox</extends>
- <header>knuminput.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
</widget>
</item>
<item>
- <widget class="QCheckBox" name="_animationsEnabled">
- <property name="text">
- <string>Enable animations</string>
- </property>
- </widget>
- </item>
- <item>
<layout class="QGridLayout" name="gridLayout_6">
<item row="3" column="0">
<widget class="QLabel" name="label_3">
</widget>
</widget>
</item>
- <item>
- <widget class="QWidget" name="_expertModeContainer" native="true">
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="1">
- <widget class="QPushButton" name="_expertModeButton">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="3">
- <widget class="QFrame" name="frame_2">
- <property name="frameShape">
- <enum>QFrame::HLine</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
</layout>
</widget>
<customwidgets>
<tabstop>_toolBarDrawItemSeparator</tabstop>
<tabstop>_checkDrawX</tabstop>
<tabstop>_cacheEnabled</tabstop>
- <tabstop>_animationsEnabled</tabstop>
<tabstop>_mnemonicsMode</tabstop>
<tabstop>_windowDragMode</tabstop>
<tabstop>_useWMMoveResize</tabstop>
- <tabstop>_expertModeButton</tabstop>
<tabstop>_viewDrawFocusIndicator</tabstop>
<tabstop>_viewDrawTreeBranchLines</tabstop>
<tabstop>_viewDrawTriangularExpander</tabstop>
<default>true</default>
</entry>
- <!-- animation flags -->
- <entry name="AnimationsEnabled" type="Bool">
- <default>true</default>
- </entry>
-
- <entry name="GenericAnimationsEnabled" type="Bool">
- <default>true</default>
- </entry>
-
- <entry name="ToolBarAnimationType" type="Enum">
- <choices>
- <choice name="TB_NONE" />
- <choice name="TB_FADE" />
- <choice name="TB_FOLLOW_MOUSE" />
- </choices>
- <default>TB_FADE</default>
- </entry>
-
- <entry name="MenuBarAnimationType" type="Enum">
- <choices>
- <choice name="MB_NONE" />
- <choice name="MB_FADE" />
- <choice name="MB_FOLLOW_MOUSE" />
- </choices>
- <default>MB_FADE</default>
- </entry>
-
- <entry name="MenuAnimationType" type="Enum">
- <choices>
- <choice name="ME_NONE" />
- <choice name="ME_FADE" />
- <choice name="ME_FOLLOW_MOUSE" />
- </choices>
- <default>ME_FADE</default>
- </entry>
-
- <entry name="ProgressBarAnimationsEnabled" type="Bool">
- <default>true</default>
- </entry>
-
- <!-- generic animation durations -->
- <entry name="GenericAnimationsDuration" type="Int">
- <default>150</default>
- </entry>
-
- <!-- toolbar follow-mouse animation durations -->
- <!-- The duration for 'fade' animation mode is GenericAnimationsDuration -->
- <entry name="ToolBarAnimationsDuration" type="Int">
- <default>50</default>
- </entry>
-
- <!-- menubar animation durations -->
- <entry name="MenuBarAnimationsDuration" type="Int">
- <default>150</default>
- </entry>
-
- <!-- menubar animation durations -->
- <entry name="MenuBarFollowMouseAnimationsDuration" type="Int">
- <default>80</default>
- </entry>
-
- <!-- menu animation durations -->
- <entry name="MenuAnimationsDuration" type="Int">
- <default>150</default>
- </entry>
-
- <!-- menu animation durations -->
- <entry name="MenuFollowMouseAnimationsDuration" type="Int">
- <default>40</default>
- </entry>
-
- <!-- progress bar animation durations -->
- <entry name="ProgressBarAnimationsDuration" type="Int">
- <default>250</default>
- </entry>
-
- <!-- progress bar animation durations -->
- <entry name="ProgressBarBusyStepDuration" type="Int">
- <default>50</default>
- </entry>
-
- <!-- transition flags -->
- <entry name="StackedWidgetTransitionsEnabled" type="Bool">
- <default>false</default>
- </entry>
-
- <entry name="LabelTransitionsEnabled" type="Bool">
- <default>true</default>
- </entry>
-
- <entry name="ComboBoxTransitionsEnabled" type="Bool">
- <default>true</default>
- </entry>
-
- <entry name="LineEditTransitionsEnabled" type="Bool">
- <default>true</default>
- </entry>
-
- <!-- transition durations -->
- <entry name="StackedWidgetTransitionsDuration" type="Int">
- <default>150</default>
- </entry>
-
- <entry name="LabelTransitionsDuration" type="Int">
- <default>75</default>
- </entry>
-
- <entry name="ComboBoxTransitionsDuration" type="Int">
- <default>75</default>
- </entry>
-
- <entry name="LineEditTransitionsDuration" type="Int">
- <default>150</default>
- </entry>
-
</group>
</kcfg>
+++ /dev/null
-#ifndef oxygenanimationmodes_h
-#define oxygenanimationmodes_h
-
-/*
-* oxygenanimationmodes.h
-* animation modes
-* -------------------
-*
-* Copyright (c) 2012 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-*
-* Largely inspired from Qtcurve style
-* Copyright (C) Craig Drummond, 2003 - 2010 craig.p.drummond@gmail.com
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2 of the License, or( at your option ) any later version.
-*
-* This library 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
-* MA 02110-1301, USA.
-*/
-
-#include "QtCore/QFlags"
-
-namespace Oxygen
-{
-
- //! animation mode
- enum AnimationMode
- {
- AnimationNone = 0,
- AnimationHover = 1<<0,
- AnimationFocus = 1<<1,
- AnimationEnable = 1<<2
- };
-
- Q_DECLARE_FLAGS(AnimationModes, AnimationMode)
-
-}
-
-#endif
}
//____________________________________________________________________________________
- void FrameShadowFactory::updateState( const QWidget* widget, bool focus, bool hover, qreal opacity, AnimationMode mode ) const
+ void FrameShadowFactory::updateState( const QWidget* widget, bool focus, bool hover, qreal opacity ) const
{
const QList<QObject *> children = widget->children();
foreach( QObject *child, children )
{
if( FrameShadowBase* shadow = qobject_cast<FrameShadowBase *>(child) )
- { shadow->updateState( focus, hover, opacity, mode ); }
+ { shadow->updateState( focus, hover, opacity ); }
}
}
}
//____________________________________________________________________________________
- void SunkenFrameShadow::updateState( bool focus, bool hover, qreal opacity, AnimationMode mode )
+ void SunkenFrameShadow::updateState( bool focus, bool hover, qreal opacity )
{
bool changed( false );
if( _focus != focus ) { _focus = focus; changed |= true; }
if( _hover != hover ) { _hover = hover; changed |= !_focus; }
- if( _mode != mode )
- {
-
- _mode = mode;
- changed |=
- (_mode == AnimationNone) ||
- (_mode == AnimationFocus) ||
- (_mode == AnimationHover && !_focus );
-
- }
- if( _opacity != opacity ) { _opacity = opacity; changed |= (_mode != AnimationNone ); }
+ if( _opacity != opacity ) { _opacity = opacity; changed |= 0; }
if( changed )
{
QPainter painter(this);
painter.setClipRegion( event->region() );
- _helper.renderHole( &painter, palette().color( QPalette::Window ), r, options, _opacity, _mode, tiles );
+ _helper.renderHole( &painter, palette().color( QPalette::Window ), r, options, _opacity, tiles );
return;
void setHasContrast( const QWidget* widget, bool ) const;
//! update state
- void updateState( const QWidget*, bool focus, bool hover, qreal opacity, AnimationMode ) const;
+ void updateState( const QWidget*, bool focus, bool hover, qreal opacity ) const;
protected:
virtual void updateGeometry( void ) = 0;
//! update state
- virtual void updateState( bool, bool, qreal, AnimationMode )
+ virtual void updateState( bool, bool, qreal )
{}
protected:
_viewHoverBrush( helper.viewHoverBrush() ),
_focus( false ),
_hover( false ),
- _opacity( -1 ),
- _mode( AnimationNone )
+ _opacity( -1 )
{ init(); }
virtual void updateGeometry( void );
//! update state
- void updateState( bool focus, bool hover, qreal opacity, AnimationMode mode );
+ void updateState( bool focus, bool hover, qreal opacity );
protected:
bool _focus;
bool _hover;
qreal _opacity;
- AnimationMode _mode;
};
#include "oxygenstyle.h"
#include "oxygenstyle.moc"
-#include "oxygenanimations.h"
#include "oxygenblurhelper.h"
#include "oxygenframeshadow.h"
#include "oxygenmdiwindowshadow.h"
#include "oxygenshadowhelper.h"
#include "oxygensplitterproxy.h"
#include "oxygenstyleconfigdata.h"
-#include "oxygentransitions.h"
#include "oxygenwidgetexplorer.h"
#include "oxygenwindowmanager.h"
#include <QtGui/QToolBar>
#include <QtGui/QToolBox>
#include <QtGui/QToolButton>
+#include <QtGui/QMenuBar>
#include <QtDBus/QDBusConnection>
_doubleButtonHeight( 28 ),
_helper( new StyleHelper( "oxygen" ) ),
_shadowHelper( new ShadowHelper( this, *_helper ) ),
- _animations( new Animations( this ) ),
- _transitions( new Transitions( this ) ),
_windowManager( new WindowManager( this ) ),
_topLevelManager( new TopLevelManager( this, *_helper ) ),
_frameShadowFactory( new FrameShadowFactory( this ) ),
if( !widget ) return;
// register widget to animations
- animations().registerWidget( widget );
- transitions().registerWidget( widget );
windowManager().registerWidget( widget );
frameShadowFactory().registerWidget( widget, helper() );
mdiWindowShadowFactory().registerWidget( widget );
{
widget->setAttribute( Qt::WA_Hover );
- animations().lineEditEngine().registerWidget( widget, AnimationHover|AnimationFocus );
}
{
// register widget to animations
- animations().unregisterWidget( widget );
- transitions().unregisterWidget( widget );
windowManager().unregisterWidget( widget );
frameShadowFactory().unregisterWidget( widget );
mdiWindowShadowFactory().unregisterWidget( widget );
flags |= Qt::TextHideMnemonic;
}
- if( animations().widgetEnabilityEngine().enabled() )
- {
-
- /*
- check if painter engine is registered to WidgetEnabilityEngine, and animated
- if yes, merge the palettes. Note: a static_cast is safe here, since only the address
- of the pointer is used, not the actual content.
- */
- const QWidget* widget( static_cast<const QWidget*>( painter->device() ) );
- if( animations().widgetEnabilityEngine().isAnimated( widget, AnimationEnable ) )
- {
-
- const QPalette pal = helper().mergePalettes( palette, animations().widgetEnabilityEngine().opacity( widget, AnimationEnable ) );
- return QCommonStyle::drawItemText( painter, r, flags, pal, enabled, text, textRole );
-
- }
-
- }
-
return QCommonStyle::drawItemText( painter, r, flags, palette, enabled, text, textRole );
}
else if( isKTextEditFrame( widget ) && widget->parentWidget()->hasFocus() )
{ focusHighlight = true; }
- // assume focus takes precedence over hover
- animations().lineEditEngine().updateState( widget, AnimationFocus, focusHighlight );
- animations().lineEditEngine().updateState( widget, AnimationHover, hoverHighlight && !focusHighlight );
-
if( flags & State_Sunken )
{
const QRect local( r.adjusted( 1, 1, -1, -1 ) );
qreal opacity( -1 );
- AnimationMode mode = AnimationNone;
- if( enabled && animations().lineEditEngine().isAnimated( widget, AnimationFocus ) )
- {
-
- opacity = animations().lineEditEngine().opacity( widget, AnimationFocus );
- mode = AnimationFocus;
-
- } else if( enabled && animations().lineEditEngine().isAnimated( widget, AnimationHover ) ) {
-
- opacity = animations().lineEditEngine().opacity( widget, AnimationHover );
- mode = AnimationHover;
-
- }
if( frameShadowFactory().isRegistered( widget ) )
{
- frameShadowFactory().updateState( widget, focusHighlight, hoverHighlight, opacity, mode );
+ frameShadowFactory().updateState( widget, focusHighlight, hoverHighlight, opacity );
} else {
helper().renderHole(
painter, palette.color( QPalette::Window ), local, options,
- opacity, mode, TileSet::Ring );
+ opacity, TileSet::Ring );
}
const bool enabled( flags & State_Enabled );
const bool mouseOver( enabled && ( flags & State_MouseOver ) );
- animations().headerViewEngine().updateState( widget, r.topLeft(), mouseOver );
- const bool animated( enabled && animations().headerViewEngine().isAnimated( widget, r.topLeft() ) );
-
// define gradient and polygon for drawing arrow
const QPolygonF a = genericArrow( orientation, ArrowNormal );
QColor color = palette.color( QPalette::WindowText );
const qreal penThickness = 1.6;
const qreal offset( qMin( penThickness, qreal( 1.0 ) ) );
- if( animated )
- {
-
- const qreal opacity( animations().headerViewEngine().opacity( widget, r.topLeft() ) );
- color = KColorUtils::mix( color, highlight, opacity );
-
- } else if( mouseOver ) color = highlight;
+ if( mouseOver ) color = highlight;
painter->translate( r.center() );
painter->translate( 0, 1 );
const State& flags( option->state );
const bool enabled( flags & State_Enabled );
const bool mouseOver( enabled && ( flags & State_MouseOver ) );
- const bool hasFocus( enabled && ( flags & State_HasFocus ) );
const QPalette& palette( option->palette );
StyleOptions opts = 0;
if( flags & State_HasFocus ) opts |= Focus;
if( enabled && ( flags & State_MouseOver ) ) opts |= Hover;
- // update animation state
- animations().widgetStateEngine().updateState( widget, AnimationHover, mouseOver );
- animations().widgetStateEngine().updateState( widget, AnimationFocus, hasFocus && !mouseOver );
-
- // store animation state
- const bool hoverAnimated( animations().widgetStateEngine().isAnimated( widget, AnimationHover ) );
- const bool focusAnimated( animations().widgetStateEngine().isAnimated( widget, AnimationFocus ) );
- const qreal hoverOpacity( animations().widgetStateEngine().opacity( widget, AnimationHover ) );
- const qreal focusOpacity( animations().widgetStateEngine().opacity( widget, AnimationFocus ) );
-
// decide if widget must be rendered flat.
/*
The decision is made depending on
if( !( opts & Sunken ) )
{
// hover rect
- if( enabled && hoverAnimated )
- {
-
- QColor glow( helper().alphaColor( helper().viewFocusBrush().brush( QPalette::Active ).color(), hoverOpacity ) );
- helper().slitFocused( glow )->render( slitRect, painter );
-
- } else if( mouseOver ) {
+ if( mouseOver ) {
helper().slitFocused( helper().viewFocusBrush().brush( QPalette::Active ).color() )->render( slitRect, painter );
// flat pressed-down buttons do not get focus effect,
// consistently with tool buttons
- if( enabled && hoverAnimated )
- {
-
- helper().renderHole( painter, palette.color( QPalette::Window ), slitRect, options, hoverOpacity, AnimationHover, TileSet::Ring );
-
- } else {
-
- helper().renderHole( painter, palette.color( QPalette::Window ), slitRect, options );
-
- }
+ helper().renderHole( painter, palette.color( QPalette::Window ), slitRect, options );
}
buttonColor = KColorUtils::mix( buttonColor, tintColor, 0.5 );
}
- if( enabled && hoverAnimated && !( opts & Sunken ) )
- {
-
- renderButtonSlab( painter, slabRect, buttonColor, opts, hoverOpacity, AnimationHover, TileSet::Ring );
-
- } else if( enabled && !mouseOver && focusAnimated && !( opts & Sunken ) ) {
-
- renderButtonSlab( painter, slabRect, buttonColor, opts, focusOpacity, AnimationFocus, TileSet::Ring );
-
- } else {
-
- renderButtonSlab( painter, slabRect, buttonColor, opts );
-
- }
+ renderButtonSlab( painter, slabRect, buttonColor, opts );
}
const bool isInToolBar( widget && qobject_cast<const QToolBar*>( widget->parent() ) );
// toolbar engine
- const bool toolBarAnimated( isInToolBar && widget && ( animations().toolBarEngine().isAnimated( widget->parentWidget() ) || animations().toolBarEngine().isFollowMouseAnimated( widget->parentWidget() ) ) );
- const QRect animatedRect( ( isInToolBar && widget ) ? animations().toolBarEngine().animatedRect( widget->parentWidget() ):QRect() );
- const QRect childRect( ( widget && widget->parentWidget() ) ? r.translated( widget->mapToParent( QPoint( 0,0 ) ) ):QRect() );
- const QRect currentRect( widget ? animations().toolBarEngine().currentRect( widget->parentWidget() ):QRect() );
- const bool current( isInToolBar && widget && widget->parentWidget() && currentRect.intersects( r.translated( widget->mapToParent( QPoint( 0,0 ) ) ) ) );
- const bool toolBarTimerActive( isInToolBar && widget && animations().toolBarEngine().isTimerActive( widget->parentWidget() ) );
- const qreal toolBarOpacity( ( isInToolBar && widget ) ? animations().toolBarEngine().opacity( widget->parentWidget() ):0 );
-
- // toolbutton engine
- if( isInToolBar && !toolBarAnimated )
- {
-
- animations().widgetStateEngine().updateState( widget, AnimationHover, mouseOver );
-
- } else {
-
- // mouseOver has precedence over focus
- animations().widgetStateEngine().updateState( widget, AnimationHover, mouseOver );
- animations().widgetStateEngine().updateState( widget, AnimationFocus, hasFocus && !mouseOver );
-
- }
-
- bool hoverAnimated( animations().widgetStateEngine().isAnimated( widget, AnimationHover ) );
- bool focusAnimated( animations().widgetStateEngine().isAnimated( widget, AnimationFocus ) );
-
- qreal hoverOpacity( animations().widgetStateEngine().opacity( widget, AnimationHover ) );
- qreal focusOpacity( animations().widgetStateEngine().opacity( widget, AnimationFocus ) );
+ const bool current( isInToolBar && widget && widget->parentWidget());
+ const bool toolBarTimerActive( isInToolBar && widget );
// slit rect
QRect slitRect( r );
}
}
- // adjust opacity and animation mode
- qreal opacity( -1 );
- AnimationMode mode( AnimationNone );
- if( enabled && hoverAnimated )
- {
- opacity = hoverOpacity;
- mode = AnimationHover;
-
- } else if( enabled && !hasFocus && focusAnimated ) {
-
- opacity = focusOpacity;
- mode = AnimationFocus;
-
- }
-
// match button color to window background
const QColor buttonColor( helper().backgroundColor( palette.color( QPalette::Button ), widget, r.center() ) );
// render slab
- renderButtonSlab( painter, slitRect, buttonColor, opts, opacity, mode, tiles );
+ renderButtonSlab( painter, slitRect, buttonColor, opts, tiles );
return true;
// fill hole
qreal opacity = 1.0;
const qreal bias = 0.75;
- if( enabled && hoverAnimated )
- {
-
- opacity = 1.0 - bias*hoverOpacity;
-
- } else if( toolBarAnimated && enabled && animatedRect.isNull() && current ) {
-
- opacity = 1.0 - bias*toolBarOpacity;
-
- } else if( enabled && (( toolBarTimerActive && current ) || mouseOver ) ) {
-
- opacity = 1.0 - bias;
-
- }
+ opacity = 1.0 - bias;
if( opacity > 0 )
{
if( hasFocus && enabled ) options |= HoleFocus;
if( mouseOver && enabled ) options |= HoleHover;
- if( enabled && hoverAnimated )
- {
-
- helper().renderHole( painter, palette.color( QPalette::Window ), slitRect, options, hoverOpacity, AnimationHover, TileSet::Ring );
-
- } else if( toolBarAnimated ) {
-
- if( enabled && animatedRect.isNull() && current )
- {
-
- helper().renderHole( painter, palette.color( QPalette::Window ), slitRect, options, toolBarOpacity, AnimationHover, TileSet::Ring );
-
- } else {
-
- helper().renderHole( painter, palette.color( QPalette::Window ), slitRect, HoleContrast );
-
- }
-
- } else if( toolBarTimerActive && current ) {
+ if( toolBarTimerActive && current ) {
helper().renderHole( painter, palette.color( QPalette::Window ), slitRect, options | HoleHover );
} else {
- if( enabled && hoverAnimated )
- {
-
- QColor glow( helper().alphaColor( helper().viewFocusBrush().brush( QPalette::Active ).color(), hoverOpacity ) );
- helper().slitFocused( glow )->render( slitRect, painter );
-
- } else if( toolBarAnimated ) {
-
- if( enabled && animatedRect.isNull() && current )
- {
- QColor glow( helper().alphaColor( helper().viewFocusBrush().brush( QPalette::Active ).color(), toolBarOpacity ) );
- helper().slitFocused( glow )->render( slitRect, painter );
- }
-
- } else if( hasFocus || mouseOver || ( toolBarTimerActive && current ) ) {
+ if( hasFocus || mouseOver || ( toolBarTimerActive && current ) ) {
helper().slitFocused( helper().viewFocusBrush().brush( QPalette::Active ).color() )->render( slitRect, painter );
const bool hasFocus( enabled && ( flags & State_HasFocus ) );
- // handle animations
- // mouseOver has precedence over focus
- animations().widgetStateEngine().updateState( widget, AnimationHover, mouseOver );
- animations().widgetStateEngine().updateState( widget, AnimationFocus, hasFocus && !mouseOver );
-
- const bool hoverAnimated( animations().widgetStateEngine().isAnimated( widget, AnimationHover ) );
- const bool focusAnimated( animations().widgetStateEngine().isAnimated( widget, AnimationFocus ) );
-
- const qreal hoverOpacity( animations().widgetStateEngine().opacity( widget, AnimationHover ) );
- const qreal focusOpacity( animations().widgetStateEngine().opacity( widget, AnimationFocus ) );
-
color = palette.color( QPalette::ButtonText );
background = helper().backgroundColor( palette.color( QPalette::Button ), widget, r.center() );
// adjust opacity and animation mode
qreal opacity( -1 );
- AnimationMode mode( AnimationNone );
- if( enabled && hoverAnimated )
- {
-
- opacity = hoverOpacity;
- mode = AnimationHover;
-
- } else if( enabled && !hasFocus && focusAnimated ) {
-
- opacity = focusOpacity;
- mode = AnimationFocus;
-
- }
// paint frame
painter->save();
if( flags & ( State_On|State_Sunken ) ) opts |= Sunken;
painter->setClipRect( frameRect.adjusted( 0, 0, -8, 0 ), Qt::IntersectClip );
- renderButtonSlab( painter, frameRect, background, opts, opacity, mode, TileSet::Bottom | TileSet::Top | TileSet::Left );
+ renderButtonSlab( painter, frameRect, background, opts, opacity, TileSet::Bottom | TileSet::Top | TileSet::Left );
} else {
if( flags & ( State_On|State_Sunken ) ) opts |= Sunken;
painter->setClipRect( frameRect.adjusted( 8, 0, 0, 0 ), Qt::IntersectClip );
- renderButtonSlab( painter, frameRect, background, opts, opacity, mode, TileSet::Bottom | TileSet::Top | TileSet::Right );
+ renderButtonSlab( painter, frameRect, background, opts, opacity, TileSet::Bottom | TileSet::Top | TileSet::Right );
}
// handle arrow over animation
const bool arrowHover( enabled && mouseOver && ( tbOption->activeSubControls & SC_ToolButtonMenu ) );
- animations().toolButtonEngine().updateState( widget, AnimationHover, arrowHover );
- const bool animated( enabled && animations().toolButtonEngine().isAnimated( widget, AnimationHover ) );
- const qreal opacity( animations().toolButtonEngine().opacity( widget, AnimationHover ) );
-
- if( animated ) color = KColorUtils::mix( color, highlight, opacity );
- else if( arrowHover ) color = highlight;
+ if( arrowHover ) color = highlight;
else color = palette.color( autoRaise ? QPalette::WindowText:QPalette::ButtonText );
}
helper().backgroundColor(
palette.color( QPalette::Button ), widget, r.center() ) );
- // mouseOver has precedence over focus
- animations().widgetStateEngine().updateState( widget, AnimationHover, mouseOver );
- animations().widgetStateEngine().updateState( widget, AnimationFocus, hasFocus&&!mouseOver );
-
- if( enabled && animations().widgetStateEngine().isAnimated( widget, AnimationHover ) )
- {
-
- const qreal opacity( animations().widgetStateEngine().opacity( widget, AnimationHover ) );
- renderCheckBox( painter, r, palette, opts, state, opacity, AnimationHover );
-
- } else if( enabled && !hasFocus && animations().widgetStateEngine().isAnimated( widget, AnimationFocus ) ) {
-
- const qreal opacity( animations().widgetStateEngine().opacity( widget, AnimationFocus ) );
- renderCheckBox( painter, r, palette, opts, state, opacity, AnimationFocus );
-
- } else renderCheckBox( painter, r, palette, opts, state );
+ renderCheckBox( painter, r, palette, opts, state );
return true;
}
QPalette palette( option->palette );
palette.setColor( QPalette::Button, helper().backgroundColor( palette.color( QPalette::Button ), widget, r.center() ) );
- // mouseOver has precedence over focus
- animations().widgetStateEngine().updateState( widget, AnimationHover, mouseOver );
- animations().widgetStateEngine().updateState( widget, AnimationFocus, hasFocus && !mouseOver );
-
CheckBoxState state;
if( flags & State_Sunken ) state = CheckSunken;
else if( flags & State_On ) state = CheckOn;
else state = CheckOff;
- if( enabled && animations().widgetStateEngine().isAnimated( widget, AnimationHover ) )
- {
-
- const qreal opacity( animations().widgetStateEngine().opacity( widget, AnimationHover ) );
- renderRadioButton( painter, r, palette, opts, state, opacity, AnimationHover );
-
- } else if( enabled && animations().widgetStateEngine().isAnimated( widget, AnimationFocus ) ) {
-
- const qreal opacity( animations().widgetStateEngine().opacity( widget, AnimationFocus ) );
- renderRadioButton( painter, r, palette, opts, state, opacity, AnimationFocus );
-
- } else renderRadioButton( painter, r, palette, opts, state );
+ renderRadioButton( painter, r, palette, opts, state );
return true;
// use the same background as in drawHeaderPrimitive
QPalette palette( option->palette );
- if( widget && animations().widgetEnabilityEngine().isAnimated( widget, AnimationEnable ) )
- { palette = helper().mergePalettes( palette, animations().widgetEnabilityEngine().opacity( widget, AnimationEnable ) ); }
-
const bool horizontal( option->state & QStyle::State_Horizontal );
const bool reverseLayout( option->direction == Qt::RightToLeft );
renderHeaderBackground( option->rect, palette, painter, widget, horizontal, reverseLayout );
const QRect& r( option->rect );
const QPalette& palette( option->palette );
- if( enabled )
- {
- const bool active( flags & State_Selected );
- const bool animated( animations().menuBarEngine().isAnimated( widget, r.topLeft() ) );
- const qreal opacity( animations().menuBarEngine().opacity( widget, r.topLeft() ) );
- const QRect currentRect( animations().menuBarEngine().currentRect( widget, r.topLeft() ) );
- const QRect animatedRect( animations().menuBarEngine().animatedRect( widget ) );
-
- const bool intersected( animatedRect.intersects( r ) );
- const bool current( currentRect.contains( r.topLeft() ) );
- const bool timerIsActive( animations().menuBarEngine().isTimerActive( widget ) );
-
- // do nothing in case of empty intersection between animated rect and current
- if( ( intersected || !animated || animatedRect.isNull() ) && ( active || animated || timerIsActive ) )
- {
-
- QColor color( helper().calcMidColor( palette.color( QPalette::Window ) ) );
- if( StyleConfigData::menuHighlightMode() != StyleConfigData::MM_DARK )
- {
-
- if( flags & State_Sunken )
- {
-
- if( StyleConfigData::menuHighlightMode() == StyleConfigData::MM_STRONG ) color = palette.color( QPalette::Highlight );
- else color = KColorUtils::mix( color, KColorUtils::tint( color, palette.color( QPalette::Highlight ), 0.6 ) );
-
- } else {
-
- if( StyleConfigData::menuHighlightMode() == StyleConfigData::MM_STRONG ) color = KColorUtils::tint( color, helper().viewHoverBrush().brush( palette ).color() );
- else color = KColorUtils::mix( color, KColorUtils::tint( color, helper().viewHoverBrush().brush( palette ).color() ) );
- }
-
- } else color = helper().backgroundColor( color, widget, r.center() );
-
- // drawing
- if( animated && intersected )
- {
-
- helper().holeFlat( color, 0.0 )->render( animatedRect.adjusted( 1,1,-1,-1 ), painter, TileSet::Full );
-
- } else if( timerIsActive && current ) {
-
- helper().holeFlat( color, 0.0 )->render( r.adjusted( 1,1,-1,-1 ), painter, TileSet::Full );
-
- } else if( animated && current ) {
-
- color.setAlphaF( opacity );
- helper().holeFlat( color, 0.0 )->render( r.adjusted( 1,1,-1,-1 ), painter, TileSet::Full );
-
- } else if( active ) {
-
- helper().holeFlat( color, 0.0 )->render( r.adjusted( 1,1,-1,-1 ), painter, TileSet::Full );
-
- }
-
- }
-
- }
-
// text
QPalette::ColorRole role( QPalette::WindowText );
if( StyleConfigData::menuHighlightMode() == StyleConfigData::MM_STRONG && ( flags & State_Sunken ) && enabled )
if( active && enabled )
{
- // check if there is a 'sliding' animation in progress, in which case, do nothing
- const QRect animatedRect( animations().menuEngine().animatedRect( widget ) );
- if( animatedRect.isNull() )
- {
-
- const bool animated( animations().menuEngine().isAnimated( widget, Current ) );
- const QRect currentRect( animations().menuEngine().currentRect( widget, Current ) );
- const bool intersected( currentRect.contains( r.topLeft() ) );
+ const QColor color( helper().menuBackgroundColor( helper().calcMidColor( palette.color( QPalette::Window ) ), widget, r.center() ) );
- const QColor color( helper().menuBackgroundColor( helper().calcMidColor( palette.color( QPalette::Window ) ), widget, r.center() ) );
-
- if( animated && intersected ) renderMenuItemRect( option, r, color, palette, painter, animations().menuEngine().opacity( widget, Current ) );
- else renderMenuItemRect( option, r, color, palette, painter );
-
- }
+ renderMenuItemRect( option, r, color, palette, painter );
}
subopt.rect = subElementRect( SE_ProgressBarGroove, pb, widget );
drawProgressBarGrooveControl( &subopt, painter, widget );
- if( animations().progressBarEngine().busyIndicatorEnabled() && pb->maximum == 0 && pb->minimum == 0 )
- { animations().progressBarEngine().startBusyTimer(); }
-
- if( animations().progressBarEngine().isAnimated( widget ) )
- { subopt.progress = animations().progressBarEngine().value( widget ); }
-
subopt.rect = subElementRect( SE_ProgressBarContents, &subopt, widget );
drawProgressBarContentsControl( &subopt, painter, widget );
// check if anything is to be drawn
qreal progress = pbOpt->progress - pbOpt->minimum;
const bool busyIndicator = ( pbOpt->minimum == 0 && pbOpt->maximum == 0 );
+#warning "busy indicator"
+#if 0
if( busyIndicator && widget )
{
// load busy value from widget property
QVariant busyValue( widget->property( ProgressBarEngine::busyValuePropertyName ) );
if( busyValue.isValid() ) progress = busyValue.toReal();
}
+#endif
if( !( progress || busyIndicator ) ) return true;
const bool enabled( flags&State_Enabled );
const bool mouseOver( enabled && ( flags&State_MouseOver ) );
- // enable animation state
- animations().scrollBarEngine().updateState( widget, enabled && ( sliderOption->activeSubControls & SC_ScrollBarSlider ) );
- const bool animated( enabled && animations().scrollBarEngine().isAnimated( widget, SC_ScrollBarSlider ) );
-
if( horizontal )
{
// render
renderScrollBarHole( painter, holeRect, palette.color( QPalette::Window ), Qt::Horizontal, tiles );
- if( animated ) renderScrollBarHandle( painter, r, palette, Qt::Horizontal, mouseOver, animations().scrollBarEngine().opacity( widget, SC_ScrollBarSlider ) );
- else renderScrollBarHandle( painter, r, palette, Qt::Horizontal, mouseOver );
+ renderScrollBarHandle( painter, r, palette, Qt::Horizontal, mouseOver );
} else {
// render
renderScrollBarHole( painter, holeRect, palette.color( QPalette::Window ), Qt::Vertical, tiles );
- if( animated ) renderScrollBarHandle( painter, r, palette, Qt::Vertical, mouseOver, animations().scrollBarEngine().opacity( widget, SC_ScrollBarSlider ) );
- else renderScrollBarHandle( painter, r, palette, Qt::Vertical, mouseOver );
+ renderScrollBarHandle( painter, r, palette, Qt::Vertical, mouseOver );
}
const bool tabBarLocked( tabBarData().locks( tabBar ) );
const bool mouseOver( enabled && !tabBarLocked && ( flags & State_MouseOver ) );
- // animation state
- animations().tabBarEngine().updateState( widget, r.topLeft(), mouseOver );
- const bool animated( enabled && !selected && !tabBarLocked && animations().tabBarEngine().isAnimated( widget, r.topLeft() ) );
-
// handle base frame painting, for tabbars in which tab is being dragged
tabBarData().drawTabBarBaseControl( tabOpt, painter, widget );
if( selected && tabBar && isDragged ) tabBarData().lock( tabBar );
// slab options
StyleOptions slabOptions( NoFill );
if( StyleConfigData::tabSubtleShadow() ) slabOptions |= SubtleShadow;
- if( ( !selected ) && ( mouseOver || animated ) ) slabOptions |= Hover;
+ if( ( !selected ) && mouseOver ) slabOptions |= Hover;
// color
const QColor color( palette.color( QPalette::Window ) );
foreach( SlabRect slab, slabs ) // krazy:exclude=foreach
{
adjustSlabRect( slab, tabWidgetRect, documentMode, verticalTabs );
- if( selected || !animated ) renderSlab( painter, slab, color, slabOptions );
+ if( selected ) renderSlab( painter, slab, color, slabOptions );
else {
- const qreal opacity( animations().tabBarEngine().opacity( widget, r.topLeft() ) );
- renderSlab( painter, slab, color, slabOptions, opacity, AnimationHover );
+ renderSlab( painter, slab, color, slabOptions);
}
// render window background in case of dragged tabwidget
renderSlab( painter, tabRect, color, slabOptions, tiles );
- } else if( animated ) {
-
- const qreal opacity( animations().tabBarEngine().opacity( widget, r.topLeft() ) );
- renderSlab( painter, tabRect, color, slabOptions, opacity, AnimationHover, tiles );
-
} else renderSlab( painter, tabRect, color, slabOptions, tiles );
// fill tab
const bool tabBarLocked( tabBarData().locks( tabBar ) );
const bool mouseOver( enabled && !tabBarLocked && ( flags & State_MouseOver ) );
- // animation state
- animations().tabBarEngine().updateState( widget, r.topLeft(), mouseOver );
- const bool animated( enabled && !selected && !tabBarLocked && animations().tabBarEngine().isAnimated( widget, r.topLeft() ) );
-
// handle base frame painting, for tabbars in which tab is being dragged
tabBarData().drawTabBarBaseControl( tabOpt, painter, widget );
if( selected && tabBar && isDragged ) tabBarData().lock( tabBar );
if( tabBar ) painter->restore();
// hovered highlight
- if( ( animated || mouseOver ) && highlightSlab._r.isValid() )
+ if( mouseOver && highlightSlab._r.isValid() )
{
- const qreal opacity( animations().tabBarEngine().opacity( widget, r.topLeft() ) );
const StyleOptions hoverTabOpts( NoFill | Hover );
adjustSlabRect( highlightSlab, tabWidgetRect, documentMode, verticalTabs );
// pass an invalid color to have only the glow painted
- if( animated ) renderSlab( painter, highlightSlab, QColor(), hoverTabOpts, opacity, AnimationHover );
- else renderSlab( painter, highlightSlab, QColor(), hoverTabOpts );
+ renderSlab( painter, highlightSlab, QColor(), hoverTabOpts );
}
//___________________________________________________________________________________
bool Style::drawToolBarControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const
{
-
- const QRect& r( option->rect );
-
- // when timeLine is running draw border event if not hovered
- const bool toolBarAnimated( animations().toolBarEngine().isFollowMouseAnimated( widget ) );
- const QRect animatedRect( animations().toolBarEngine().animatedRect( widget ) );
- const bool toolBarIntersected( toolBarAnimated && animatedRect.intersects( r ) );
- if( toolBarIntersected )
- { helper().slitFocused( helper().viewFocusBrush().brush( QPalette::Active ).color() )->render( animatedRect, painter ); }
-
// draw nothing otherwise ( toolbars are transparent )
return true;
const QStyleOptionToolBoxV2 *v2 = qstyleoption_cast<const QStyleOptionToolBoxV2 *>( option );
if( v2 && v2->position == QStyleOptionToolBoxV2::Beginning && selected ) return true;
- /*
- the proper widget ( the toolbox tab ) is not passed as argument by Qt.
- What is passed is the toolbox directly. To implement animations properly,
- the painter->device() is used instead
- */
- bool animated( false );
- qreal opacity( AnimationData::OpacityInvalid );
- if( enabled )
- {
- // try retrieve button from painter device.
- if( QPaintDevice* device = painter->device() )
- {
- animations().toolBoxEngine().updateState( device, mouseOver );
- animated = animations().toolBoxEngine().isAnimated( device );
- opacity = animations().toolBoxEngine().opacity( device );
- }
-
- }
-
// save colors for shadow
/* important: option returns a wrong color. We use the widget's palette when widget is set */
const QColor color( widget ? widget->palette().color( widget->backgroundRole() ) : palette.color( QPalette::Window ) );
QList<QColor> colors;
colors.push_back( helper().calcLightColor( color ) );
- if( mouseOver || animated )
+ if( mouseOver )
{
QColor highlight = helper().viewHoverBrush().brush( palette ).color();
- if( animated )
- {
-
- colors.push_back( KColorUtils::mix( dark, highlight, opacity ) );
- colors.push_back( helper().alphaColor( highlight, 0.2*opacity ) );
-
- } else {
-
- colors.push_back( highlight );
- colors.push_back( helper().alphaColor( highlight, 0.2 ) );
-
- }
+ colors.push_back( highlight );
+ colors.push_back( helper().alphaColor( highlight, 0.2 ) );
} else colors.push_back( dark );
if( ( flags & ( State_Sunken|State_On ) ) && !editable ) opts |= Sunken;
const QColor inputColor( palette.color( QPalette::Base ) );
- const QRect editField( subControlRect( CC_ComboBox, cb, SC_ComboBoxEditField, widget ) );
if( editable )
{
// editable combobox. Make it look like a LineEdit
- // focus takes precedence over hover
- animations().lineEditEngine().updateState( widget, AnimationFocus, hasFocus );
- animations().lineEditEngine().updateState( widget, AnimationHover, mouseOver && !hasFocus );
const QRect fr( r.adjusted( 1,1,-1,-1 ) );
if( mouseOver && enabled ) options |= HoleHover;
const QColor color( palette.color( QPalette::Window ) );
- if( enabled && animations().lineEditEngine().isAnimated( widget, AnimationFocus ) )
- {
-
- helper().renderHole( painter, color, fr, options, animations().lineEditEngine().opacity( widget, AnimationFocus ), AnimationFocus, TileSet::Ring );
-
- } else if( enabled && animations().lineEditEngine().isAnimated( widget, AnimationHover ) ) {
-
- helper().renderHole( painter, color, fr, options, animations().lineEditEngine().opacity( widget, AnimationHover ), AnimationHover, TileSet::Ring );
-
- } else {
-
- helper().renderHole( painter, color, fr, options );
-
- }
+ helper().renderHole( painter, color, fr, options );
}
} else {
// non editable combobox. Make it look like a PushButton
- // hover takes precedence over focus
- animations().lineEditEngine().updateState( widget, AnimationHover, mouseOver );
- animations().lineEditEngine().updateState( widget, AnimationFocus, hasFocus && !mouseOver );
-
- // store animation state
- const bool hoverAnimated( animations().lineEditEngine().isAnimated( widget, AnimationHover ) );
- const bool focusAnimated( animations().lineEditEngine().isAnimated( widget, AnimationFocus ) );
- const qreal hoverOpacity( animations().lineEditEngine().opacity( widget, AnimationHover ) );
- const qreal focusOpacity( animations().lineEditEngine().opacity( widget, AnimationFocus ) );
// blend button color to the background
const QColor buttonColor( helper().backgroundColor( palette.color( QPalette::Button ), widget, r.center() ) );
if( !( opts & Sunken ) )
{
// hover rect
- if( enabled && hoverAnimated )
- {
-
- QColor glow( helper().alphaColor( helper().viewFocusBrush().brush( QPalette::Active ).color(), hoverOpacity ) );
- helper().slitFocused( glow )->render( slitRect, painter );
-
- } else if( mouseOver ) {
+ if( mouseOver ) {
helper().slitFocused( helper().viewFocusBrush().brush( QPalette::Active ).color() )->render( slitRect, painter );
HoleOptions options( HoleContrast );
if( mouseOver && enabled ) options |= HoleHover;
- // flat pressed-down buttons do not get focus effect,
- // consistently with tool buttons
- if( enabled && hoverAnimated )
- {
-
- helper().renderHole( painter, palette.color( QPalette::Window ), slitRect, options, hoverOpacity, AnimationHover, TileSet::Ring );
-
- } else {
-
- helper().renderHole( painter, palette.color( QPalette::Window ), slitRect, options );
-
- }
+ helper().renderHole( painter, palette.color( QPalette::Window ), slitRect, options );
}
} else {
- if( enabled && hoverAnimated )
- {
-
- renderButtonSlab( painter, slabRect, buttonColor, opts, hoverOpacity, AnimationHover, TileSet::Ring );
-
- } else if( enabled && focusAnimated ) {
-
- renderButtonSlab( painter, slabRect, buttonColor, opts, focusOpacity, AnimationFocus, TileSet::Ring );
-
- } else {
-
- renderButtonSlab( painter, slabRect, buttonColor, opts );
-
- }
+ renderButtonSlab( painter, slabRect, buttonColor, opts );
}
// check animation state
const bool subControlHover( enabled && mouseOver && cb->activeSubControls&SC_ComboBoxArrow );
- animations().comboBoxEngine().updateState( widget, AnimationHover, subControlHover );
-
- const bool animated( enabled && animations().comboBoxEngine().isAnimated( widget, AnimationHover ) );
- const qreal opacity( animations().comboBoxEngine().opacity( widget, AnimationHover ) );
- if( animated )
- {
-
- QColor highlight = helper().viewHoverBrush().brush( palette ).color();
- color = KColorUtils::mix( palette.color( QPalette::Text ), highlight, opacity );
-
- } else if( subControlHover ) {
+ if( subControlHover ) {
color = helper().viewHoverBrush().brush( palette ).color();
if( hasFocus ) opts |= Focus;
if( mouseOver ) opts |= Hover;
- // mouseOver has precedence over focus
- animations().widgetStateEngine().updateState( widget, AnimationHover, mouseOver );
- animations().widgetStateEngine().updateState( widget, AnimationFocus, hasFocus && !mouseOver );
-
const QRect rect( option->rect );
const QPalette &palette( option->palette );
const QColor buttonColor( helper().backgroundColor( palette.color( QPalette::Button ), widget, rect.center() ) );
- if( enabled && animations().widgetStateEngine().isAnimated( widget, AnimationHover ) && !( opts & Sunken ) )
- {
-
- qreal opacity( animations().widgetStateEngine().opacity( widget, AnimationHover ) );
- renderDialSlab( painter, rect, buttonColor, option, opts, opacity, AnimationHover );
-
- } else if( enabled && !mouseOver && animations().widgetStateEngine().isAnimated( widget, AnimationFocus ) && !( opts & Sunken ) ) {
-
- qreal opacity( animations().widgetStateEngine().opacity( widget, AnimationFocus ) );
- renderDialSlab( painter, rect, buttonColor, option, opts, opacity, AnimationFocus );
-
- } else {
-
- renderDialSlab( painter, rect, buttonColor, option, opts );
-
- }
+ renderDialSlab( painter, rect, buttonColor, option, opts );
return true;
if( hasFocus ) opts |= Focus;
if( handleActive && mouseOver ) opts |= Hover;
- animations().sliderEngine().updateState( widget, enabled && handleActive );
- const qreal opacity( animations().sliderEngine().opacity( widget ) );
-
const QColor color( helper().backgroundColor( palette.color( QPalette::Button ), widget, r.center() ) );
- const QColor glow( slabShadowColor( color, opts, opacity, AnimationHover ) );
+ const QColor glow( slabShadowColor( color, opts, -1 ) );
const bool sunken( flags & (State_On|State_Sunken) );
painter->drawPixmap( r.topLeft(), helper().sliderSlab( color, glow, sunken, 0.0 ) );
if( mouseOver && enabled ) options |= HoleHover;
QColor local( palette.color( QPalette::Window ) );
- animations().lineEditEngine().updateState( widget, AnimationHover, mouseOver );
- animations().lineEditEngine().updateState( widget, AnimationFocus, hasFocus );
- if( enabled && animations().lineEditEngine().isAnimated( widget, AnimationFocus ) )
- {
-
- helper().renderHole( painter, local, fr, options, animations().lineEditEngine().opacity( widget, AnimationFocus ), AnimationFocus, TileSet::Ring );
-
- } else if( enabled && animations().lineEditEngine().isAnimated( widget, AnimationHover ) ) {
-
- helper().renderHole( painter, local, fr, options, animations().lineEditEngine().opacity( widget, AnimationHover ), AnimationHover, TileSet::Ring );
-
- } else {
-
- helper().renderHole( painter, local, fr, options );
-
- }
+ helper().renderHole( painter, local, fr, options );
}
}
{
QRect textRect = subControlRect( CC_TitleBar, tb, SC_TitleBarLabel, widget );
- // enable state transition
- animations().widgetEnabilityEngine().updateState( widget, AnimationEnable, active );
-
// make sure palette has the correct color group
QPalette palette( option->palette );
- if( animations().widgetEnabilityEngine().isAnimated( widget, AnimationEnable ) )
- { palette = helper().mergePalettes( palette, animations().widgetEnabilityEngine().opacity( widget, AnimationEnable ) ); }
-
palette.setCurrentColorGroup( active ? QPalette::Active: QPalette::Disabled );
QCommonStyle::drawItemText( painter, textRect, Qt::AlignCenter, palette, active, tb->text, QPalette::WindowText );
// check autoRaise state
const State flags( option->state );
- const bool isInToolBar( widget && qobject_cast<QToolBar*>( widget->parent() ) );
// get rect and palette
- const QRect& rect( option->rect );
const QStyleOptionToolButton *tool( qstyleoption_cast<const QStyleOptionToolButton *>( option ) );
if( !tool ) return true;
- const bool enabled( flags & State_Enabled );
- const bool mouseOver( enabled && ( flags & State_MouseOver ) );
- const bool hasFocus( enabled && ( flags&State_HasFocus ) );
- const bool sunken( flags & ( State_Sunken|State_On ) );
-
- if( isInToolBar )
- {
-
- animations().widgetStateEngine().updateState( widget, AnimationHover, mouseOver );
-
- } else {
-
- // mouseOver has precedence over focus
- animations().widgetStateEngine().updateState( widget, AnimationHover, mouseOver );
- animations().widgetStateEngine().updateState( widget, AnimationFocus, hasFocus&&!mouseOver );
-
- }
-
- // toolbar animation
- QWidget* parent( widget ? widget->parentWidget():0 );
- const bool toolBarAnimated( isInToolBar && animations().toolBarEngine().isAnimated( parent ) );
- const QRect animatedRect( animations().toolBarEngine().animatedRect( parent ) );
- const QRect currentRect( animations().toolBarEngine().currentRect( parent ) );
- const bool current( isInToolBar && currentRect.intersects( rect.translated( widget->mapToParent( QPoint( 0,0 ) ) ) ) );
- const bool toolBarTimerActive( isInToolBar && animations().toolBarEngine().isTimerActive( widget->parentWidget() ) );
-
- // normal toolbutton animation
- const bool hoverAnimated( animations().widgetStateEngine().isAnimated( widget, AnimationHover ) );
- const bool focusAnimated( animations().widgetStateEngine().isAnimated( widget, AnimationFocus ) );
-
/* FIXME: this all logic is messy. The conditions to trigger the call to drawPrimitive can likely be simplified */
// local copy of option
const QRect buttonRect( subControlRect( CC_ToolButton, tool, SC_ToolButton, widget ) );
- bool drawn(false);
- if( enabled && !( mouseOver || hasFocus || sunken ) )
- {
-
- if( hoverAnimated || ( focusAnimated && !hasFocus ) || ( ( ( toolBarAnimated && animatedRect.isNull() )||toolBarTimerActive ) && current ) )
- {
- tOpt.rect = buttonRect;
- tOpt.state = flags;
- drawPanelButtonToolPrimitive( &tOpt, painter, widget );
- drawn = true;
- }
-
- }
-
// State_AutoRaise: only draw button when State_MouseOver
State bflags = tool->state;
if( bflags & State_AutoRaise && !( bflags & State_MouseOver ) )
tOpt.state = bflags;
- if( tool->subControls & SC_ToolButton && ( bflags & ( State_Sunken | State_On | State_Raised ) ) && !drawn )
+ if( tool->subControls & SC_ToolButton && ( bflags & ( State_Sunken | State_On | State_Raised ) ) )
{
tOpt.rect = buttonRect;
drawPanelButtonToolPrimitive( &tOpt, painter, widget );
blurHelper().setEnabled( true );
// reinitialize engines
- animations().setupEngines();
- transitions().setupEngines();
windowManager().initialize();
shadowHelper().reloadConfig();
}
//_________________________________________________________________________________
- void Style::renderDialSlab( QPainter *painter, const QRect& r, const QColor &color, const QStyleOption *option, StyleOptions opts, qreal opacity, AnimationMode mode ) const
+ void Style::renderDialSlab( QPainter *painter, const QRect& r, const QColor &color, const QStyleOption *option, StyleOptions opts, qreal opacity ) const
{
// cast option
const QRect rect( centerRect( r, dimension, dimension ) );
// calculate glow color
- const QColor glow( slabShadowColor( color, opts, opacity, mode ) );
+ const QColor glow( slabShadowColor( color, opts, opacity ) );
// get main slab
QPixmap pix( helper().dialSlab( color, glow, 0.0, dimension ) );
//____________________________________________________________________________________
void Style::renderButtonSlab( QPainter *painter, QRect r, const QColor &color, StyleOptions options, qreal opacity,
- AnimationMode mode,
TileSet::Tiles tiles ) const
{
if( ( r.width() <= 0 ) || ( r.height() <= 0 ) ) return;
} else {
- QColor glow = slabShadowColor( color, options, opacity, mode );
+ QColor glow = slabShadowColor( color, options, opacity );
tile = helper().slab( color, glow, 0.0 );
}
QPainter *painter, QRect r,
const QColor &color,
StyleOptions options, qreal opacity,
- AnimationMode mode,
TileSet::Tiles tiles ) const
{
} else {
// calculate proper glow color based on current settings and opacity
- const QColor glow( slabShadowColor( color, options, opacity, mode ) );
+ const QColor glow( slabShadowColor( color, options, opacity) );
if( color.isValid() || glow.isValid() ) tile = helper().slab( color, glow , 0.0 );
else return;
// check animation state
const bool subControlHover( enabled && mouseOver && ( option->activeSubControls & subControl ) );
- animations().spinBoxEngine().updateState( widget, subControl, subControlHover );
-
- const bool animated( enabled && animations().spinBoxEngine().isAnimated( widget, subControl ) );
- const qreal opacity( animations().spinBoxEngine().opacity( widget, subControl ) );
QColor color;
- if( animated )
- {
-
- QColor highlight = helper().viewHoverBrush().brush( palette ).color();
- color = KColorUtils::mix( palette.color( QPalette::Text ), highlight, opacity );
-
- } else if( subControlHover ) {
+ if( subControlHover ) {
color = helper().viewHoverBrush().brush( palette ).color();
const bool enabled( flags & State_Enabled );
const bool mouseOver( enabled && ( flags & ( State_MouseOver|State_Sunken ) ) );
- // get orientation
- const Qt::Orientation orientation( horizontal ? Qt::Horizontal : Qt::Vertical );
-
- bool animated( false );
- qreal opacity( AnimationData::OpacityInvalid );
-
- if( enabled )
- {
- if( qobject_cast<const QMainWindow*>( widget ) )
- {
-
- animations().dockSeparatorEngine().updateRect( widget, r, orientation, mouseOver );
- animated = animations().dockSeparatorEngine().isAnimated( widget, r, orientation );
- opacity = animated ? animations().dockSeparatorEngine().opacity( widget, orientation ) : AnimationData::OpacityInvalid;
-
- } else if( QPaintDevice* device = painter->device() ) {
-
- /*
- try update QSplitterHandle using painter device, because Qt passes
- QSplitter as the widget to the QStyle primitive.
- */
- animations().splitterEngine().updateState( device, mouseOver );
- animated = animations().splitterEngine().isAnimated( device );
- opacity = animations().splitterEngine().opacity( device );
-
- }
- }
-
// get base color
const QColor color = palette.color( QPalette::Background );
const int hCenter = r.center().x();
const int h = r.height();
- if( animated || mouseOver )
+ if( mouseOver )
{
- const QColor highlight = helper().alphaColor( helper().calcLightColor( color ),0.5*( animated ? opacity:1.0 ) );
+ const QColor highlight = helper().alphaColor( helper().calcLightColor( color ),0 );
const qreal a( r.height() > 30 ? 10.0/r.height():0.1 );
QLinearGradient lg( 0, r.top(), 0, r.bottom() );
lg.setColorAt( 0, Qt::transparent );
const int vCenter( r.center().y() );
const int w( r.width() );
- if( animated || mouseOver )
+ if( mouseOver )
{
- const QColor highlight( helper().alphaColor( helper().calcLightColor( color ),0.5*( animated ? opacity:1.0 ) ) );
+ const QColor highlight( helper().alphaColor( helper().calcLightColor( color ),0 ) );
const qreal a( r.width() > 30 ? 10.0/r.width():0.1 );
QLinearGradient lg( r.left(), 0, r.right(), 0 );
lg.setColorAt( 0, Qt::transparent );
const bool enabled( flags & State_Enabled );
const bool active( enabled && ( option->titleBarState & Qt::WindowActive ) );
- // enable state transition
- animations().widgetEnabilityEngine().updateState( widget, AnimationEnable, active );
- if( animations().widgetEnabilityEngine().isAnimated( widget, AnimationEnable ) )
- { palette = helper().mergePalettes( palette, animations().widgetEnabilityEngine().opacity( widget, AnimationEnable ) ); }
-
const bool sunken( flags&State_Sunken );
const bool mouseOver( ( !sunken ) && widget && r.translated( widget->mapToGlobal( QPoint( 0,0 ) ) ).contains( QCursor::pos() ) );
- animations().mdiWindowEngine().updateState( widget, subControl, enabled && mouseOver );
- const bool animated( enabled && animations().mdiWindowEngine().isAnimated( widget, subControl ) );
- const qreal opacity( animations().mdiWindowEngine().opacity( widget, subControl ) );
-
// contrast color
const QColor base =option->palette.color( QPalette::Active, QPalette::Window );
// icon color
QColor color;
- if( animated )
- {
-
- const QColor base( palette.color( active ? QPalette::Active : QPalette::Disabled, QPalette::WindowText ) );
- const QColor glow( subControl == SC_TitleBarCloseButton ?
- helper().viewNegativeTextBrush().brush( palette ).color():
- helper().viewHoverBrush().brush( palette ).color() );
-
- color = KColorUtils::mix( base, glow, opacity );
-
- } else if( mouseOver ) {
+ if( mouseOver ) {
color = ( subControl == SC_TitleBarCloseButton ) ?
helper().viewNegativeTextBrush().brush( palette ).color():
//__________________________________________________________________________
void Style::renderMenuItemBackground( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const
{
- const QRect& r( option->rect );
- const QPalette& palette( option->palette );
- const QRect animatedRect( animations().menuEngine().animatedRect( widget ) );
- if( !animatedRect.isNull() )
- {
-
- if( animatedRect.intersects( r ) )
- {
- const QColor color( helper().menuBackgroundColor( helper().calcMidColor( palette.color( QPalette::Window ) ), widget, animatedRect.center() ) );
- renderMenuItemRect( option, animatedRect, color, palette, painter );
- }
-
- } else if( animations().menuEngine().isTimerActive( widget ) ) {
-
- const QRect previousRect( animations().menuEngine().currentRect( widget, Previous ) );
- if( previousRect.intersects( r ) )
- {
-
- const QColor color( helper().menuBackgroundColor( helper().calcMidColor( palette.color( QPalette::Window ) ), widget, previousRect.center() ) );
- renderMenuItemRect( option, previousRect, color, palette, painter );
- }
-
- } else if( animations().menuEngine().isAnimated( widget, Previous ) ) {
-
- QRect previousRect( animations().menuEngine().currentRect( widget, Previous ) );
- if( previousRect.intersects( r ) )
- {
- const qreal opacity( animations().menuEngine().opacity( widget, Previous ) );
- const QColor color( helper().menuBackgroundColor( helper().calcMidColor( palette.color( QPalette::Window ) ), widget, previousRect.center() ) );
- renderMenuItemRect( option, previousRect, color, palette, painter, opacity );
- }
-
- }
-
return;
}
void Style::renderCheckBox(
QPainter *painter, const QRect &rect, const QPalette &palette,
StyleOptions options, CheckBoxState state,
- qreal opacity,
- AnimationMode mode ) const
+ qreal opacity) const
{
const int s( qMin( rect.width(), rect.height() ) );
if( !( options & NoFill ) )
{
if( options & Sunken ) helper().holeFlat( palette.color( QPalette::Window ), 0.0, false )->render( r, painter, TileSet::Full );
- else renderSlab( painter, r, palette.color( QPalette::Button ), options, opacity, mode, TileSet::Ring );
+ else renderSlab( painter, r, palette.color( QPalette::Button ), options, TileSet::Ring );
}
// check mark
const QPalette& palette,
StyleOptions options,
CheckBoxState state,
- qreal opacity,
- AnimationMode mode ) const
+ qreal opacity ) const
{
const int s( CheckBox_Size );
const int y = r.y();
const QColor color( palette.color( QPalette::Button ) );
- const QColor glow( slabShadowColor( color, options, opacity, mode ) );
+ const QColor glow( slabShadowColor( color, options, opacity ) );
painter->drawPixmap( x, y, helper().roundSlab( color, glow, 0.0 ) );
// draw the radio mark
//______________________________________________________________________________
QColor Style::scrollBarArrowColor( const QStyleOptionSlider* option, const SubControl& control, const QWidget* widget ) const
{
- const QRect& r( option->rect );
const QPalette& palette( option->palette );
QColor color( palette.color( QPalette::WindowText ) );
}
- const bool hover( animations().scrollBarEngine().isHovered( widget, control ) );
- const bool animated( animations().scrollBarEngine().isAnimated( widget, control ) );
- const qreal opacity( animations().scrollBarEngine().opacity( widget, control ) );
-
- // retrieve mouse position from engine
- QPoint position( hover ? animations().scrollBarEngine().position( widget ) : QPoint( -1, -1 ) );
- if( hover && r.contains( position ) )
- {
- // need to update the arrow controlRect on fly because there is no
- // way to get it from the styles directly, outside of repaint events
- animations().scrollBarEngine().setSubControlRect( widget, control, r );
- }
-
-
- if( r.intersects( animations().scrollBarEngine().subControlRect( widget, control ) ) )
- {
-
- QColor highlight = helper().viewHoverBrush().brush( palette ).color();
- if( animated )
- {
- color = KColorUtils::mix( color, highlight, opacity );
-
- } else if( hover ) {
-
- color = highlight;
-
- }
-
- }
-
return color;
}
}
//____________________________________________________________________________________
- QColor Style::slabShadowColor( QColor color, StyleOptions options, qreal opacity, AnimationMode mode ) const
+ QColor Style::slabShadowColor( QColor color, StyleOptions options, qreal opacity ) const
{
QColor glow;
- if( mode == AnimationNone || opacity < 0 )
+ if( opacity < 0 )
{
if( options & Hover ) glow = helper().viewHoverBrush().brush( QPalette::Active ).color();
else if( ( options & SubtleShadow ) && color.isValid() ) glow = helper().alphaColor( helper().calcShadowColor( color ), 0.15 );
- } else if( mode == AnimationHover ) {
-
- // animated color, hover
- if( options & Focus ) glow = helper().viewFocusBrush().brush( QPalette::Active ).color();
- else if( ( options & SubtleShadow ) && color.isValid() ) glow = helper().alphaColor( helper().calcShadowColor( color ), 0.15 );
-
- if( glow.isValid() ) glow = KColorUtils::mix( glow, helper().viewHoverBrush().brush( QPalette::Active ).color(), opacity );
- else glow = helper().alphaColor( helper().viewHoverBrush().brush( QPalette::Active ).color(), opacity );
-
- } else if( mode == AnimationFocus ) {
-
- if( options & Hover ) glow = helper().viewHoverBrush().brush( QPalette::Active ).color();
- else if( ( options & SubtleShadow ) && color.isValid() ) glow = helper().alphaColor( helper().calcShadowColor( color ), 0.15 );
-
- if( glow.isValid() ) glow = KColorUtils::mix( glow, helper().viewFocusBrush().brush( QPalette::Active ).color(), opacity );
- else glow = helper().alphaColor( helper().viewFocusBrush().brush( QPalette::Active ).color(), opacity );
-
}
return glow;
// Boston, MA 02110-1301, USA.
//////////////////////////////////////////////////////////////////////////////
-#include "oxygenanimationmodes.h"
#include "oxygenmetrics.h"
#include "oxygentileset.h"
//@}
- //! animations
- Animations& animations( void ) const
- { return *_animations; }
-
- Transitions& transitions( void ) const
- { return *_transitions; }
-
//! window manager
WindowManager& windowManager( void ) const
{ return *_windowManager; }
//! qdial slab
void renderDialSlab( QPainter* p, const QRect& r, const QColor& c, const QStyleOption* option, StyleOptions opts = 0 ) const
- { renderDialSlab( p, r, c, option, opts, -1, AnimationNone ); }
+ { renderDialSlab( p, r, c, option, opts, -1 ); }
//! qdial slab
- void renderDialSlab( QPainter*, const QRect&, const QColor&, const QStyleOption*, StyleOptions, qreal, AnimationMode ) const;
+ void renderDialSlab( QPainter*, const QRect&, const QColor&, const QStyleOption*, StyleOptions, qreal ) const;
//! generic button slab
void renderButtonSlab( QPainter* p, QRect r, const QColor& c, StyleOptions opts = 0, TileSet::Tiles tiles = TileSet::Ring) const
- { renderButtonSlab( p, r, c, opts, -1, AnimationNone, tiles ); }
+ { renderButtonSlab( p, r, c, opts, -1, tiles ); }
//! generic button slab
- void renderButtonSlab( QPainter*, QRect, const QColor&, StyleOptions, qreal, AnimationMode, TileSet::Tiles ) const;
+ void renderButtonSlab( QPainter*, QRect, const QColor&, StyleOptions, qreal, TileSet::Tiles ) const;
//! generic slab
void renderSlab( QPainter* painter, const SlabRect& slab, const QColor& color, StyleOptions options = 0 ) const
//! generic slab
void renderSlab( QPainter* painter, QRect rect, const QColor& color, StyleOptions options = 0, TileSet::Tiles tiles = TileSet::Ring) const
- { renderSlab( painter, rect, color, options, -1, AnimationNone, tiles ); }
+ { renderSlab( painter, rect, color, options, -1, tiles ); }
//! generic slab
- void renderSlab( QPainter* painter, const SlabRect& slab, const QColor& color, StyleOptions options, qreal opacity, AnimationMode mode ) const
- { renderSlab( painter, slab._r, color, options, opacity, mode, slab._tiles ); }
+ void renderSlab( QPainter* painter, const SlabRect& slab, const QColor& color, StyleOptions options, qreal opacity ) const
+ { renderSlab( painter, slab._r, color, options, opacity, slab._tiles ); }
//! generic slab
- void renderSlab( QPainter*, QRect, const QColor&, StyleOptions, qreal, AnimationMode, TileSet::Tiles ) const;
+ void renderSlab( QPainter*, QRect, const QColor&, StyleOptions, qreal, TileSet::Tiles ) const;
// render tab background
void renderTabBackground( QPainter*, const QRect&, const QPalette&, const QTabBar::Shape, const QWidget* ) const;
};
//! checkbox
- void renderCheckBox( QPainter*, const QRect&, const QPalette&, StyleOptions, CheckBoxState, qreal opacity = -1, AnimationMode mode = AnimationNone ) const;
+ void renderCheckBox( QPainter*, const QRect&, const QPalette&, StyleOptions, CheckBoxState, qreal opacity = -1) const;
//! radio button
- void renderRadioButton( QPainter*, const QRect&, const QPalette&, StyleOptions, CheckBoxState, qreal opacity = -1, AnimationMode mode = AnimationNone ) const;
+ void renderRadioButton( QPainter*, const QRect&, const QPalette&, StyleOptions, CheckBoxState, qreal opacity = -1 ) const;
//! scrollbar hole
void renderScrollBarHole( QPainter*, const QRect&, const QColor&, const Qt::Orientation&, const TileSet::Tiles& = TileSet::Full ) const;
//@}
//! slab glowing color
- QColor slabShadowColor( QColor, StyleOptions, qreal, AnimationMode ) const;
+ QColor slabShadowColor( QColor, StyleOptions, qreal ) const;
//! returns point position for generic arrows
QPolygonF genericArrow( ArrowOrientation, ArrowSize = ArrowNormal ) const;
//! shadow helper
ShadowHelper* _shadowHelper;
- //! animations
- Animations* _animations;
-
- //! transitions
- Transitions* _transitions;
-
//! window manager
WindowManager* _windowManager;
}
//____________________________________________________________________________________
- void StyleHelper::renderHole( QPainter* p, const QColor& base, const QRect& r, HoleOptions options, qreal opacity, Oxygen::AnimationMode animationMode, TileSet::Tiles tiles )
+ void StyleHelper::renderHole( QPainter* p, const QColor& base, const QRect& r, HoleOptions options, qreal opacity, TileSet::Tiles tiles )
{
if( !r.isValid() ) return;
- if( opacity >= 0 && ( animationMode & Oxygen::AnimationFocus ) )
- {
-
- // calculate proper glow color based on current settings and opacity
- const QColor glow( (options&HoleHover) ?
- KColorUtils::mix( viewHoverBrush().brush( QPalette::Active ).color(), viewFocusBrush().brush( QPalette::Active ).color(), opacity ):
- alphaColor( viewFocusBrush().brush( QPalette::Active ).color(), opacity ) );
-
- hole( base, glow, 7, options )->render( r, p, tiles );
-
- } else if( options & HoleFocus ) {
+ if( options & HoleFocus ) {
const QColor glow( viewFocusBrush().brush( QPalette::Active ).color() );
hole( base, glow, 7, options )->render( r, p, tiles );
- } else if( opacity >= 0 && ( animationMode & Oxygen::AnimationHover ) ) {
-
- // calculate proper glow color based on current settings and opacity
- const QColor glow( alphaColor( viewHoverBrush().brush( QPalette::Active ).color(), opacity ) );
- hole( base, glow, 7, options )->render( r, p, tiles );
-
- } else if( options & HoleHover ) {
+ } else if( options & HoleHover ) {
const QColor glow( viewHoverBrush().brush( QPalette::Active ).color() );
hole( base, glow, 7, options )->render( r, p, tiles );
*/
#include "oxygenhelper.h"
-#include "oxygenanimationmodes.h"
#include <KWindowSystem>
#include <KDebug>
void renderHole( QPainter *p, const QColor& color, const QRect &r,
HoleOptions options = 0,
TileSet::Tiles tiles = TileSet::Ring )
- { renderHole( p, color, r, options, -1, Oxygen::AnimationNone, tiles ); }
+ { renderHole( p, color, r, options, -1, tiles ); }
//! generic hole (with animated glow)
void renderHole(
QPainter*, const QColor&, const QRect &r,
HoleOptions,
- qreal opacity, Oxygen::AnimationMode animationMode,
+ qreal opacity,
TileSet::Tiles = TileSet::Ring );
TileSet *holeFlat( const QColor&, qreal shade, bool fill = true, int size = 7 );
+++ /dev/null
-// krazy:excludeall=qclasses
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygencomboboxdata.cpp
-// data container for QComboBox transition
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygencomboboxdata.h"
-#include "oxygencomboboxdata.moc"
-
-namespace Oxygen
-{
-
- //______________________________________________________
- ComboBoxData::ComboBoxData( QObject* parent, QComboBox* target, int duration ):
- TransitionData( parent, target, duration ),
- _target( target )
- {
- _target.data()->installEventFilter( this );
- connect( _target.data(), SIGNAL(destroyed()), SLOT(targetDestroyed()) );
- connect( _target.data(), SIGNAL(currentIndexChanged(int)), SLOT(indexChanged()) );
- }
-
- //___________________________________________________________________
- void ComboBoxData::indexChanged( void )
- {
-
- if( recursiveCheck() ) return;
-
- if( transition().data()->isAnimated() )
- { transition().data()->endAnimation(); }
-
- if( initializeAnimation() ) animate();
- else transition().data()->hide();
-
- }
-
- //___________________________________________________________________
- bool ComboBoxData::eventFilter( QObject* object, QEvent* event )
- {
-
- // make sure engine is enabled
- if( !( enabled() && object == _target.data() ) )
- { return TransitionData::eventFilter( object, event ); }
-
- // make sure that target is not editable
- if( _target.data()->isEditable() )
- { return TransitionData::eventFilter( object, event ); }
-
- switch( event->type() )
- {
-
- case QEvent::Show:
- case QEvent::Resize:
- case QEvent::Move:
- if( !recursiveCheck() && _target.data()->isVisible() )
- { _timer.start( 0, this ); }
- break;
-
- default: break;
- }
-
- return TransitionData::eventFilter( object, event );
-
- }
-
- //___________________________________________________________________
- void ComboBoxData::timerEvent( QTimerEvent* event )
- {
- if( event->timerId() == _timer.timerId() )
- {
-
- _timer.stop();
- if( enabled() && transition() && _target && !_target.data()->isVisible() )
- {
- setRecursiveCheck( true );
- transition().data()->setEndPixmap( transition().data()->grab( _target.data(), targetRect() ) );
- setRecursiveCheck( false );
- }
-
- } else return TransitionData::timerEvent( event );
-
- }
-
- //___________________________________________________________________
- bool ComboBoxData::initializeAnimation( void )
- {
- if( !( enabled() && _target && _target.data()->isVisible() ) ) return false;
- if( _target.data()->isEditable() )
- {
- /*
- do nothing for editable comboboxes because
- lineEditor animations are handled directly
- */
- return false;
- }
-
- transition().data()->setOpacity(0);
- transition().data()->setGeometry( targetRect() );
- transition().data()->setStartPixmap( transition().data()->currentPixmap() );
- transition().data()->show();
- transition().data()->raise();
- return true;
- }
-
- //___________________________________________________________________
- bool ComboBoxData::animate( void )
- {
-
- // check enability
- if( !enabled() ) return false;
-
- // grab
- setRecursiveCheck( true );
- transition().data()->setEndPixmap( transition().data()->grab( _target.data(), targetRect() ) );
- setRecursiveCheck( false );
-
- // start animation
- transition().data()->animate();
-
- return true;
-
- }
-
- //___________________________________________________________________
- void ComboBoxData::targetDestroyed( void )
- {
- setEnabled( false );
- _target.clear();
- }
-
-}
+++ /dev/null
-#ifndef oxygencombobox_datah
-#define oxygencombobox_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygencomboboxdata.h
-// data container for QComboBox transition
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygentransitiondata.h"
-
-#include <QtCore/QString>
-#include <QtCore/QBasicTimer>
-#include <QtCore/QTimerEvent>
-#include <QtGui/QComboBox>
-#include <QtGui/QLineEdit>
-
-namespace Oxygen
-{
-
- //! generic data
- class ComboBoxData: public TransitionData
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- ComboBoxData( QObject*, QComboBox*, int );
-
- //! destructor
- virtual ~ComboBoxData( void )
- {}
-
- //! event filter
- virtual bool eventFilter( QObject*, QEvent* );
-
- protected:
-
- //! timer event
- virtual void timerEvent( QTimerEvent* );
-
- //! target rect
- /*! return rect corresponding to the area to be updated when animating */
- QRect targetRect( void ) const
- { return _target ? _target.data()->rect().adjusted( 5, 5, -5, -5 ):QRect(); }
-
- protected slots:
-
- //! triggered when item is activated in combobox
- virtual void indexChanged( void );
-
- //! initialize animation
- virtual bool initializeAnimation( void );
-
- //! animate
- virtual bool animate( void );
-
- //! called when target is destroyed
- virtual void targetDestroyed( void );
-
- private:
-
- //! needed to start animations out of parent paintEvent
- QBasicTimer _timer;
-
- //! target
- QWeakPointer<QComboBox> _target;
-
- };
-
-}
-
-#endif
+++ /dev/null
-// krazy:excludeall=qclasses
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygencomboboxengine.cpp
-// stores event filters and maps widgets to animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygencomboboxengine.h"
-#include "oxygencomboboxengine.moc"
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- bool ComboBoxEngine::registerWidget( QComboBox* widget )
- {
-
- if( !widget ) return false;
- if( !_data.contains( widget ) ) { _data.insert( widget, new ComboBoxData( this, widget, duration() ), enabled() ); }
-
- // connect destruction signal
- disconnect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)) );
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)) );
-
- return true;
-
- }
-
-}
+++ /dev/null
-#ifndef oxygencomboboxengine_h
-#define oxygencomboboxengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygencomboboxengine.h
-// stores event filters and maps widgets to animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygencomboboxdata.h"
-
-namespace Oxygen
-{
-
- //! used for simple widgets
- class ComboBoxEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit ComboBoxEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~ComboBoxEngine( void )
- {}
-
- //! register widget
- virtual bool registerWidget( QComboBox* );
-
- //! duration
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! maps
- DataMap<ComboBoxData> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenlabeldata.cpp
-// data container for QLabel transition
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenlabeldata.h"
-#include "oxygenlabeldata.moc"
-
-#include <QtCore/QEvent>
-#include <QtCore/QTextStream>
-#include <QtGui/QPainter>
-
-namespace Oxygen
-{
-
- // use 300 milliseconds for animation lock
- const int LabelData::_lockTime = 300;
-
- //______________________________________________________
- LabelData::LabelData( QObject* parent, QLabel* target, int duration ):
- TransitionData( parent, target, duration ),
- _target( target )
- {
- _target.data()->installEventFilter( this );
-
- const bool hasProxy( _target.data()->graphicsProxyWidget() );
- const bool hasMessageWidget( hasParent( target, "KMessageWidget" ) );
-
- transition().data()->setFlags( hasProxy||hasMessageWidget ? TransitionWidget::Transparent : TransitionWidget::GrabFromWindow );
-
- connect( _target.data(), SIGNAL(destroyed()), SLOT(targetDestroyed()) );
-
- }
-
- //___________________________________________________________________
- bool LabelData::eventFilter( QObject* object, QEvent* event )
- {
-
- if( object != _target.data() ) return TransitionData::eventFilter( object, event );
- switch( event->type() )
- {
-
- case QEvent::Show:
- /*
- at show event, on set the old text to current
- to avoid animate the "first" paint event.
- text mnemonic is always removed to avoid triggering the animation when only the
- latter is changed
- */
- _text = _target.data()->text().remove( '&' );
- break;
-
- case QEvent::Paint:
- {
-
- if( enabled() && _target )
- {
-
- // remove showMnemonic from text before comparing
- QString text( _target.data()->text().remove( '&' ) );
- if( text == _text )
- {
- if(
- transparent() &&
- transition().data()->isAnimated() &&
- TransitionWidget::paintEnabled() ) return true;
- else break;
- }
-
- // update text and pixmap
- _text = text;
-
- if( !(transition() && _target.data()->isVisible() ) ) break;
-
- if( transition().data()->isAnimated() )
- { transition().data()->endAnimation(); }
-
- // check whether animations are locked
- if( isLocked() )
- {
-
- // hide transition widget
- transition().data()->hide();
-
- // restart the lock timer
- // and abort transition
- lockAnimations();
- break;
- }
-
- // restart the lock timer
- // and prepare transition
- lockAnimations();
- initializeAnimation();
- _timer.start( 0, this );
-
- if( !transition().data()->startPixmap().isNull() && TransitionWidget::paintEnabled() )
- {
-
- // show the transition widget
- // and disable this event painting
- transition().data()->show();
- transition().data()->raise();
- if( transparent() ) return true;
- else break;
-
- } else {
-
- // hide transition widget and abort transition
- transition().data()->hide();
- break;
-
- }
-
- } else if( transition().data()->isAnimated() && TransitionWidget::paintEnabled() ) {
-
- // disable painting when transition is running
- // since label is obscured by transition widget
- return true;
-
- } else break;
- }
-
- default: break;
- }
-
- return TransitionData::eventFilter( object, event );
-
- }
-
- //___________________________________________________________________
- void LabelData::timerEvent( QTimerEvent* event )
- {
- if( event->timerId() == _timer.timerId() )
- {
-
- _timer.stop();
-
- // check transition and widget validity
- if( !( enabled() && _target && transition() ) ) return;
-
- // assign end pixmap
- transition().data()->setEndPixmap( transition().data()->grab( _target.data() ) );
-
- // start animation
- animate();
-
- } else if( event->timerId() == _animationLockTimer.timerId() ) {
-
- unlockAnimations();
-
- // check transition and widget validity
- if( !( enabled() && _target && transition() ) ) return;
-
- // reassign end pixmap for the next transition to be properly initialized
- transition().data()->setEndPixmap( transition().data()->grab( _target.data() ) );
-
- } else return TransitionData::timerEvent( event );
-
- }
-
- //___________________________________________________________________
- bool LabelData::initializeAnimation( void )
- {
-
- transition().data()->setOpacity(0);
- QRect current( _target.data()->geometry() );
- if( _widgetRect.isValid() && _widgetRect != current )
- {
-
- _widgetRect = current;
- transition().data()->resetStartPixmap();
- transition().data()->resetEndPixmap();
- return false;
-
- }
-
- transition().data()->setStartPixmap( transition().data()->currentPixmap() );
- transition().data()->setGeometry( _target.data()->rect() );
- _widgetRect = current;
- return true;
- }
-
- //___________________________________________________________________
- bool LabelData::animate( void )
- {
-
- if( transition().data()->startPixmap().isNull() ) return false;
-
- transition().data()->animate();
- return true;
-
- }
-
- //___________________________________________________________________
- void LabelData::targetDestroyed( void )
- {
- setEnabled( false );
- _target.clear();
- }
-
-}
+++ /dev/null
-#ifndef oxygenlabel_datah
-#define oxygenlabel_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenlabeldata.h
-// data container for QLabel transition
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygentransitiondata.h"
-
-#include <QtCore/QString>
-#include <QtCore/QBasicTimer>
-#include <QtGui/QLabel>
-
-namespace Oxygen
-{
-
- //! generic data
- class LabelData: public TransitionData
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- LabelData( QObject*, QLabel*, int );
-
- //! destructor
- virtual ~LabelData( void )
- {}
-
- //! event filter
- virtual bool eventFilter( QObject*, QEvent* );
-
- //! returns true if animations are locked
- bool isLocked( void ) const
- { return _animationLockTimer.isActive(); }
-
- //! start lock animation timer
- void lockAnimations( void )
- { _animationLockTimer.start( _lockTime, this ); }
-
- //! start lock animation timer
- void unlockAnimations( void )
- { _animationLockTimer.stop(); }
-
- protected slots:
-
- //! initialize animation
- virtual bool initializeAnimation( void );
-
- //! animate
- virtual bool animate( void );
-
- //! called when target is destroyed
- virtual void targetDestroyed( void );
-
- protected:
-
- //! true if transparent
- bool transparent( void ) const
- { return transition() && transition().data()->testFlag( TransitionWidget::Transparent ); }
-
- //! timer event
- virtual void timerEvent( QTimerEvent* );
-
- private:
-
- //! lock time (milliseconds
- static const int _lockTime;
-
- //! timer used to disable animations when triggered too early
- QBasicTimer _animationLockTimer;
-
- //! needed to start animations out of parent paintEvent
- QBasicTimer _timer;
-
- //! target
- QWeakPointer<QLabel> _target;
-
- //! old text
- QString _text;
-
- //! widget rect
- /*! needed to properly handle QLabel geometry changes */
- QRect _widgetRect;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenlabelengine.cpp
-// stores event filters and maps widgets to animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenlabelengine.h"
-#include "oxygenlabelengine.moc"
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- bool LabelEngine::registerWidget( QLabel* widget )
- {
-
- if( !widget ) return false;
- if( !_data.contains( widget ) ) { _data.insert( widget, new LabelData( this, widget, duration() ), enabled() ); }
-
- // connect destruction signal
- disconnect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)) );
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)) );
-
- return true;
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenlabelengine_h
-#define oxygenlabelengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenlabelengine.h
-// stores event filters and maps widgets to animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygenlabeldata.h"
-
-namespace Oxygen
-{
-
- //! used for simple widgets
- class LabelEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit LabelEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~LabelEngine( void )
- {}
-
- //! register widget
- virtual bool registerWidget( QLabel* );
-
- //! duration
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! maps
- DataMap<LabelData> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-// krazy:excludeall=qclasses
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenlineeditdata.cpp
-// data container for QLineEdit transition
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenlineeditdata.h"
-#include "oxygenlineeditdata.moc"
-
-#include <QtCore/QEvent>
-#include <QtGui/QDateTimeEdit>
-#include <QtGui/QDoubleSpinBox>
-#include <QtGui/QPainter>
-#include <QtGui/QSpinBox>
-#include <QtGui/QStyle>
-#include <QtGui/QStyleOptionFrameV2>
-
-namespace Oxygen
-{
-
- // use 20 milliseconds for animation lock
- const int LineEditData::_lockTime = 20;
-
- //______________________________________________________
- LineEditData::LineEditData( QObject* parent, QLineEdit* target, int duration ):
- TransitionData( parent, target, duration ),
- _target( target ),
- _hasClearButton( false ),
- _edited( false )
- {
- _target.data()->installEventFilter( this );
-
- checkClearButton();
-
- connect( _target.data(), SIGNAL(destroyed()), SLOT(targetDestroyed()) );
- connect( _target.data(), SIGNAL(textEdited(QString)), SLOT(textEdited()) );
- connect( _target.data(), SIGNAL(textChanged(QString)), SLOT(textChanged()) );
-
- /*
- Additional signal/slot connections depending on widget's parent.
- This is needed because parents sometime disable the textChanged signal of the embedded
- QLineEdit
- */
- if( qobject_cast<QSpinBox*>( _target.data()->parentWidget() ) ||qobject_cast<QDoubleSpinBox*>( _target.data()->parentWidget() ) )
- {
-
- connect( _target.data()->parentWidget(), SIGNAL(valueChanged(QString)), SLOT(textChanged()) );
-
- } else if( qobject_cast<QDateTimeEdit*>( _target.data()->parentWidget() ) ) {
-
- connect( _target.data()->parentWidget(), SIGNAL(dateTimeChanged(QDateTime)), SLOT(textChanged()) );
-
- }
-
- // update cached pixmap on selection change
- connect( _target.data(), SIGNAL(selectionChanged()), SLOT(selectionChanged()) );
-
- }
-
- //___________________________________________________________________
- bool LineEditData::eventFilter( QObject* object, QEvent* event )
- {
-
- if( !( enabled() && object && object == _target.data() ) )
- { return TransitionData::eventFilter( object, event ); }
-
- switch ( event->type() )
- {
- case QEvent::Show:
- case QEvent::Resize:
- case QEvent::Move:
- transition().data()->setEndPixmap( QPixmap() );
- break;
-
- default: break;
- }
-
- return TransitionData::eventFilter( object, event );
-
- }
-
- //___________________________________________________________________
- void LineEditData::timerEvent( QTimerEvent* event )
- {
- if( event->timerId() == _timer.timerId() )
- {
-
- _timer.stop();
- checkClearButton();
- if( enabled() && transition() && _target && _target.data()->isVisible() )
- {
- setRecursiveCheck( true );
- transition().data()->setEndPixmap( transition().data()->grab( _target.data(), targetRect() ) );
- setRecursiveCheck( false );
- }
-
- } else if( event->timerId() == _animationLockTimer.timerId() ) {
-
- unlockAnimations();
-
- } else return TransitionData::timerEvent( event );
-
- }
-
- //___________________________________________________________________
- void LineEditData::checkClearButton( void )
- {
- if( !_target ) return;
- QObjectList children( _target.data()->children() );
- _hasClearButton = false;
- foreach( QObject* child, children )
- {
- if( child->inherits( "KLineEditButton" ) )
- {
- _hasClearButton = true;
- _clearButtonRect = static_cast<QWidget*>(child)->geometry();
- break;
- }
- }
-
- return;
- }
-
- //___________________________________________________________________
- void LineEditData::textEdited( void )
- {
- _edited = true;
- if( !recursiveCheck() )
- { _timer.start( 0, this ); }
- }
-
-
- //___________________________________________________________________
- void LineEditData::selectionChanged( void )
- {
- if( !recursiveCheck() )
- { _timer.start( 0, this ); }
- }
-
- //___________________________________________________________________
- void LineEditData::textChanged( void )
- {
-
- // check whether text change was triggered manually
- // in which case do not start transition
- if( _edited )
- {
- _edited = false;
- return;
- }
-
- if( transition().data()->isAnimated() )
- { transition().data()->endAnimation(); }
-
- if( isLocked() )
- {
- // if locked one do not start the new animation, to prevent flicker
- // instead, one hides the transition pixmap, trigger an update, and return.
- // animations are re-locked.
- transition().data()->hide();
- lockAnimations();
- _timer.start( 0, this );
- return;
- }
-
- if( initializeAnimation() )
- {
-
- lockAnimations();
- animate();
-
- } else {
-
- transition().data()->hide();
-
- }
- }
-
- //___________________________________________________________________
- bool LineEditData::initializeAnimation( void )
- {
- if( !( enabled() && _target && _target.data()->isVisible() ) ) return false;
-
- if( recursiveCheck() ) return false;
-
- QRect current( targetRect() );
-
- transition().data()->setOpacity(0);
- transition().data()->setGeometry( current );
-
- if( _widgetRect.isValid() &&
- !transition().data()->currentPixmap().isNull() &&
- _widgetRect != current )
- {
-
- // if label geometry has changed since last animation
- // one must clone the pixmap to make it match the right
- // geometry before starting the animation.
- QPixmap pixmap( current.size() );
- pixmap.fill( Qt::transparent );
- QPainter p( &pixmap );
- p.drawPixmap( _widgetRect.topLeft() - current.topLeft(), transition().data()->currentPixmap() );
- p.end();
- transition().data()->setStartPixmap( pixmap );
-
- } else {
-
- transition().data()->setStartPixmap( transition().data()->currentPixmap() );
-
- }
-
- bool valid( !transition().data()->startPixmap().isNull() );
- if( valid )
- {
- transition().data()->show();
- transition().data()->raise();
- }
-
- setRecursiveCheck( true );
- transition().data()->setEndPixmap( transition().data()->grab( _target.data(), targetRect() ) );
- setRecursiveCheck( false );
-
- return valid;
-
- }
-
- //___________________________________________________________________
- bool LineEditData::animate( void )
- {
- transition().data()->animate();
- return true;
- }
-
- //___________________________________________________________________
- void LineEditData::targetDestroyed( void )
- {
- setEnabled( false );
- _target.clear();
- }
-
-}
+++ /dev/null
-#ifndef oxygenlineedit_datah
-#define oxygenlineedit_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenlineeditdata.h
-// data container for QLineEdit transition
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygentransitiondata.h"
-
-#include <QtCore/QString>
-#include <QtCore/QBasicTimer>
-#include <QtGui/QLineEdit>
-
-namespace Oxygen
-{
-
- //! generic data
- class LineEditData: public TransitionData
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- LineEditData( QObject*, QLineEdit*, int );
-
- //! destructor
- virtual ~LineEditData( void )
- {}
-
- //! event filter
- bool eventFilter( QObject*, QEvent* );
-
- //! returns true if animations are locked
- bool isLocked( void ) const
- { return _animationLockTimer.isActive(); }
-
- //! start lock animation timer
- void lockAnimations( void )
- { _animationLockTimer.start( _lockTime, this ); }
-
- //! start lock animation timer
- void unlockAnimations( void )
- { _animationLockTimer.stop(); }
-
- protected slots:
-
- //! text edited
- virtual void textEdited( void );
-
- //! selection changed
- virtual void selectionChanged( void );
-
- //! text changed
- virtual void textChanged( void );
-
- //! initialize animation
- virtual bool initializeAnimation( void );
-
- //! animate
- virtual bool animate( void );
-
- //! called when target is destroyed
- virtual void targetDestroyed( void );
-
- protected:
-
- //! timer event
- virtual void timerEvent( QTimerEvent* );
-
- //! target rect
- /*! return rect corresponding to the area to be updated when animating */
- QRect targetRect( void ) const
- {
- if( !_target ) return QRect();
- QRect out( _target.data()->rect() );
- if( _hasClearButton && _clearButtonRect.isValid() )
- { out.setRight( _clearButtonRect.left() ); }
-
- return out;
- }
-
- //! check if target has clear button
- void checkClearButton( void );
-
- private:
-
- //! lock time (milliseconds
- static const int _lockTime;
-
- //! timer used to disable animations when triggered too early
- QBasicTimer _animationLockTimer;
-
- //! needed to start animations out of parent paintEvent
- QBasicTimer _timer;
-
- //! target
- QWeakPointer<QLineEdit> _target;
-
- //! true if target has clean button
- bool _hasClearButton;
-
- //! clear button rect
- QRect _clearButtonRect;
-
- //! true if text was manually edited
- /*! needed to trigger animation only on programatically enabled text */
- bool _edited;
-
- //! old text
- QString _text;
-
- //! widget rect
- /*! needed to properly handle QLabel geometry changes */
- QRect _widgetRect;
-
- };
-
-}
-
-#endif
+++ /dev/null
-// krazy:excludeall=qclasses
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenlineeditengine.cpp
-// stores event filters and maps widgets to animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenlineeditengine.h"
-#include "oxygenlineeditengine.moc"
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- bool LineEditEngine::registerWidget( QLineEdit* widget )
- {
-
- // check enability and widget validity
- if( !widget ) return false;
-
- // do not register widget if painted in a scene
- if( widget->graphicsProxyWidget() ) return false;
-
- // insert in map if needed
- if( !_data.contains( widget ) ) {
-
- _data.insert( widget, new LineEditData( this, widget, duration() ), enabled() );
-
- }
-
- // connect destruction signal
- disconnect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)) );
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)) );
-
- return true;
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenlineeditengine_h
-#define oxygenlineeditengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenlineeditengine.h
-// stores event filters and maps widgets to animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygenlineeditdata.h"
-
-namespace Oxygen
-{
-
- //! used for simple widgets
- class LineEditEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit LineEditEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~LineEditEngine( void )
- {}
-
- //! register widget
- virtual bool registerWidget( QLineEdit* );
-
- //! duration
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! maps
- DataMap<LineEditData> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenstackedwidgetdata.cpp
-// data container for QStackedWidget transition
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenstackedwidgetdata.h"
-#include "oxygenstackedwidgetdata.moc"
-
-namespace Oxygen
-{
-
- //______________________________________________________
- StackedWidgetData::StackedWidgetData( QObject* parent, QStackedWidget* target, int duration ):
- TransitionData( parent, target, duration ),
- _target( target ),
- _index( target->currentIndex() )
- {
-
- // configure transition
- connect( _target.data(), SIGNAL(destroyed()), SLOT(targetDestroyed()) );
- connect( _target.data(), SIGNAL(currentChanged(int)), SLOT(animate()) );
-
- // disable focus
- transition().data()->setAttribute(Qt::WA_NoMousePropagation, true);
- transition().data()->setFlag(TransitionWidget::PaintOnWidget, true);
-
- setMaxRenderTime( 50 );
-
- }
-
- //___________________________________________________________________
- bool StackedWidgetData::initializeAnimation( void )
- {
-
- // check enability
- if( !( _target && _target.data()->isVisible() ) )
- { return false; }
-
- // check index
- if( _target.data()->currentIndex() == _index )
- { return false; }
-
- // do not animate if either index or currentIndex is not valid
- // but update _index none the less
- if( _target.data()->currentIndex() < 0 || _index < 0 )
- {
- _index = _target.data()->currentIndex();
- return false;
- }
-
- // get old widget (matching _index) and initialize transition
- if( QWidget *widget = _target.data()->widget( _index ) )
- {
-
- transition().data()->setOpacity( 0 );
- startClock();
- transition().data()->setGeometry( widget->geometry() );
- transition().data()->setStartPixmap( transition().data()->grab( widget ) );
-
- _index = _target.data()->currentIndex();
- return !slow();
-
- } else {
-
- _index = _target.data()->currentIndex();
- return false;
-
- }
-
- }
-
- //___________________________________________________________________
- bool StackedWidgetData::animate( void )
- {
-
- // check enability
- if( !enabled() ) return false;
-
- // initialize animation
- if( !initializeAnimation() ) return false;
-
- // show transition widget
- transition().data()->show();
- transition().data()->raise();
- transition().data()->animate();
- return true;
-
- }
-
- //___________________________________________________________________
- void StackedWidgetData::finishAnimation( void )
- {
- // disable updates on currentWidget
- if( _target && _target.data()->currentWidget() )
- { _target.data()->currentWidget()->setUpdatesEnabled( false ); }
-
- // hide transition
- transition().data()->hide();
-
- // reenable updates and repaint
- if( _target && _target.data()->currentWidget() )
- {
- _target.data()->currentWidget()->setUpdatesEnabled( true );
- _target.data()->currentWidget()->repaint();
- }
-
- // invalidate start widget
- transition().data()->resetStartPixmap();
-
- }
-
- //___________________________________________________________________
- void StackedWidgetData::targetDestroyed( void )
- {
- setEnabled( false );
- _target.clear();
- }
-
-}
+++ /dev/null
-#ifndef oxygenstackedwidget_datah
-#define oxygenstackedwidget_datah
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenstackedwidgetdata.h
-// data container for QStackedWidget transition
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygentransitiondata.h"
-
-#include <QtGui/QStackedWidget>
-
-namespace Oxygen
-{
-
- //! generic data
- class StackedWidgetData: public TransitionData
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- StackedWidgetData( QObject*, QStackedWidget*, int );
-
- //! destructor
- virtual ~StackedWidgetData( void )
- {}
-
- protected slots:
-
- //! initialize animation
- virtual bool initializeAnimation( void );
-
- //! animate
- virtual bool animate( void );
-
- //! finish animation
- virtual void finishAnimation( void );
-
- //! called when target is destroyed
- virtual void targetDestroyed( void );
-
- private:
-
- //! target
- QWeakPointer<QStackedWidget> _target;
-
- //! current index
- int _index;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenstackedwidgetengine.cpp
-// stores event filters and maps widgets to animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenstackedwidgetengine.h"
-#include "oxygenstackedwidgetengine.moc"
-
-namespace Oxygen
-{
-
- //____________________________________________________________
- bool StackedWidgetEngine::registerWidget( QStackedWidget* widget )
- {
-
- if( !widget ) return false;
- if( !_data.contains( widget ) ) { _data.insert( widget, new StackedWidgetData( this, widget, duration() ), enabled() ); }
-
- // connect destruction signal
- disconnect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)) );
- connect( widget, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterWidget(QObject*)) );
-
- return true;
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenstackedwidgetengine_h
-#define oxygenstackedwidgetengine_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenstackedwidgetengine.h
-// stores event filters and maps widgets to animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseengine.h"
-#include "oxygendatamap.h"
-#include "oxygenstackedwidgetdata.h"
-
-namespace Oxygen
-{
-
- //! used for simple widgets
- class StackedWidgetEngine: public BaseEngine
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit StackedWidgetEngine( QObject* parent ):
- BaseEngine( parent )
- {}
-
- //! destructor
- virtual ~StackedWidgetEngine( void )
- {}
-
- //! register widget
- virtual bool registerWidget( QStackedWidget* );
-
- //! duration
- virtual void setEnabled( bool value )
- {
- BaseEngine::setEnabled( value );
- _data.setEnabled( value );
- }
-
- //! duration
- virtual void setDuration( int value )
- {
- BaseEngine::setDuration( value );
- _data.setDuration( value );
- }
-
- public slots:
-
- //! remove widget from map
- virtual bool unregisterWidget( QObject* object )
- { return _data.unregisterWidget( object ); }
-
- private:
-
- //! maps
- DataMap<StackedWidgetData> _data;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygentransitiondata.cpp
-// data container for generic transitions
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygentransitiondata.h"
-#include "oxygentransitiondata.moc"
-
-namespace Oxygen
-{
-
- //_________________________________________________________________
- TransitionData::TransitionData( QObject* parent, QWidget* target, int duration ):
- QObject( parent ),
- _enabled( true ),
- _recursiveCheck( false ),
- _maxRenderTime( 200 ),
- _transition( new TransitionWidget( target, duration ) )
- {
- transition().data()->hide();
- connect( transition().data(), SIGNAL(finished()), SLOT(finishAnimation()) );
- }
-
- //_________________________________________________________________
- TransitionData::~TransitionData( void )
- { if( transition() ) transition().data()->deleteLater(); }
-
-}
+++ /dev/null
-#ifndef oxygentransitiondata_h
-#define oxygentransitiondata_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygentransitiondata.h
-// data container for generic transitions
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygentransitionwidget.h"
-
-#include <QtCore/QObject>
-#include <QtCore/QTime>
-#include <QtGui/QWidget>
-
-namespace Oxygen
-{
-
- //! generic data
- class TransitionData: public QObject
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- TransitionData( QObject* parent, QWidget* target, int );
-
- //! destructor
- virtual ~TransitionData( void );
-
- //! enability
- virtual void setEnabled( bool value )
- { _enabled = value; }
-
- //! enability
- virtual bool enabled( void ) const
- { return _enabled; }
-
- //! duration
- virtual void setDuration( int duration )
- {
- if( transition() )
- { transition().data()->setDuration( duration ); }
- }
-
- //! max render time
- void setMaxRenderTime( int value )
- { _maxRenderTime = value; }
-
- //! max renderTime
- const int& maxRenderTime( void ) const
- { return _maxRenderTime; }
-
- //! start clock
- void startClock( void )
- {
- if( _clock.isNull() ) _clock.start();
- else _clock.restart();
- }
-
- //! check if rendering is two slow
- bool slow( void ) const
- { return !( _clock.isNull() || _clock.elapsed() <= maxRenderTime() ); }
-
- protected slots:
-
- //! initialize animation
- virtual bool initializeAnimation( void ) = 0;
-
- //! animate
- virtual bool animate( void ) = 0;
-
- //! finish animation
- virtual void finishAnimation( void )
- {
- if( transition() )
- { transition().data()->hide(); }
- }
-
- protected:
-
- //! returns true if one parent matches given class name
- inline bool hasParent( const QWidget*, const char* ) const;
-
- //! transition widget
- virtual const TransitionWidget::Pointer& transition( void ) const
- { return _transition; }
-
- //! used to avoid recursion when grabbing widgets
- void setRecursiveCheck( bool value )
- { _recursiveCheck = value; }
-
- //! used to avoid recursion when grabbing widgets
- bool recursiveCheck( void ) const
- { return _recursiveCheck; }
-
- private:
-
- //! enability
- bool _enabled;
-
- //! used to avoid recursion when grabbing widgets
- bool _recursiveCheck;
-
- //! timer used to detect slow rendering
- QTime _clock;
-
- //! max render time
- /*! used to detect slow rendering */
- int _maxRenderTime;
-
- //! animation handling
- TransitionWidget::Pointer _transition;
-
- };
-
- //_____________________________________________________________________________________
- bool TransitionData::hasParent( const QWidget* widget, const char* className ) const
- {
- if( !widget ) return false;
- for( QWidget* parent = widget->parentWidget(); parent; parent = parent->parentWidget() )
- { if( parent->inherits( className ) ) return true; }
-
- return false;
- }
-
-}
-
-#endif
+++ /dev/null
-// krazy:excludeall=qclasses
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygentransitions.cpp
-// container for all transition engines
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygentransitions.h"
-#include "oxygentransitions.moc"
-#include "oxygenpropertynames.h"
-#include "oxygenstyleconfigdata.h"
-
-namespace Oxygen
-{
-
- //________________________________________________________--
- Transitions::Transitions( QObject* parent ):
- QObject( parent )
- {
-
- registerEngine( _comboBoxEngine = new ComboBoxEngine( this ) );
- registerEngine( _labelEngine = new LabelEngine( this ) );
- registerEngine( _lineEditEngine = new LineEditEngine( this ) );
- registerEngine( _stackedWidgetEngine = new StackedWidgetEngine( this ) );
-
- }
-
- //________________________________________________________--
- void Transitions::setupEngines( void )
- {
-
- // animation steps
- TransitionWidget::setSteps( StyleConfigData::animationSteps() );
-
- // default enability, duration and maxFrame
- bool animationsEnabled( StyleConfigData::animationsEnabled() );
-
- // enability
- comboBoxEngine().setEnabled( animationsEnabled && StyleConfigData::comboBoxTransitionsEnabled() );
- labelEngine().setEnabled( animationsEnabled && StyleConfigData::labelTransitionsEnabled() );
- lineEditEngine().setEnabled( animationsEnabled && StyleConfigData::lineEditTransitionsEnabled() );
- stackedWidgetEngine().setEnabled( animationsEnabled && StyleConfigData::stackedWidgetTransitionsEnabled() );
-
- // durations
- comboBoxEngine().setDuration( StyleConfigData::comboBoxTransitionsDuration() );
- labelEngine().setDuration( StyleConfigData::labelTransitionsDuration() );
- lineEditEngine().setDuration( StyleConfigData::lineEditTransitionsDuration() );
- stackedWidgetEngine().setDuration( StyleConfigData::stackedWidgetTransitionsDuration() );
-
- }
-
- //____________________________________________________________
- void Transitions::registerWidget( QWidget* widget ) const
- {
-
- if( !widget ) return;
-
- // check against noAnimations propery
- QVariant propertyValue( widget->property( PropertyNames::noAnimations ) );
- if( propertyValue.isValid() && propertyValue.toBool() ) return;
-
-
- if( QLabel* label = qobject_cast<QLabel*>( widget ) ) {
-
- // do not animate labels from tooltips
- if( widget->window() && widget->window()->windowFlags().testFlag( Qt::ToolTip ) ) return;
- else if( widget->window() && widget->window()->inherits( "KWin::GeometryTip" ) ) return;
- else labelEngine().registerWidget( label );
-
- } else if( QComboBox* comboBox = qobject_cast<QComboBox*>( widget ) ) {
-
- comboBoxEngine().registerWidget( comboBox );
-
- } else if( QLineEdit* lineEdit = qobject_cast<QLineEdit*>( widget ) ) {
-
- lineEditEngine().registerWidget( lineEdit );
-
- } else if( QStackedWidget* stack = qobject_cast<QStackedWidget*>( widget ) ) {
-
- stackedWidgetEngine().registerWidget( stack );
-
- }
-
- }
-
- //____________________________________________________________
- void Transitions::unregisterWidget( QWidget* widget ) const
- {
-
- if( !widget ) return;
-
- // the following allows some optimization of widget unregistration
- // it assumes that a widget can be registered atmost in one of the
- // engines stored in the list.
- foreach( const BaseEngine::Pointer& engine, _engines )
- { if( engine && engine.data()->unregisterWidget( widget ) ) break; }
-
- }
-
-}
+++ /dev/null
-#ifndef oxygentransitions_h
-#define oxygentransitions_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygentransitions.h
-// container for all transition engines
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygencomboboxengine.h"
-#include "oxygenlabelengine.h"
-#include "oxygenlineeditengine.h"
-#include "oxygenstackedwidgetengine.h"
-
-namespace Oxygen
-{
-
- //! stores engines
- class Transitions: public QObject
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit Transitions( QObject* );
-
- //! destructor
- virtual ~Transitions( void )
- {}
-
- //! register animations corresponding to given widget, depending on its type.
- void registerWidget( QWidget* widget ) const;
-
- /*! unregister all animations associated to a widget */
- void unregisterWidget( QWidget* widget ) const;
-
- //! qlabel engine
- ComboBoxEngine& comboBoxEngine( void ) const
- { return *_comboBoxEngine; }
-
- //! qlabel engine
- LabelEngine& labelEngine( void ) const
- { return *_labelEngine; }
-
- //! qlineedit engine
- LineEditEngine& lineEditEngine( void ) const
- { return *_lineEditEngine; }
-
- //! stacked widget engine
- StackedWidgetEngine& stackedWidgetEngine( void ) const
- { return *_stackedWidgetEngine; }
-
- public slots:
-
- //! setup engines
- void setupEngines( void );
-
- private:
-
- //! register new engine
- void registerEngine( BaseEngine* engine )
- { _engines.push_back( engine ); }
-
- //! qcombobox engine
- ComboBoxEngine* _comboBoxEngine;
-
- //! qlabel engine
- LabelEngine* _labelEngine;
-
- //! qlineedit engine
- LineEditEngine* _lineEditEngine;
-
- //! stacked widget engine
- StackedWidgetEngine* _stackedWidgetEngine;
-
- //! keep list of existing engines
- QList< BaseEngine::Pointer > _engines;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygentransitionwidget.cpp
-// stores event filters and maps widgets to transitions for transitions
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygentransitionwidget.h"
-#include "oxygentransitionwidget.moc"
-
-#include <cassert>
-#include <QtGui/QPainter>
-#include <QtGui/QPaintEvent>
-#include <QtGui/QStyleOption>
-#include <QtCore/QCoreApplication>
-#include <QtCore/QTextStream>
-
-namespace Oxygen
-{
-
- //________________________________________________
- bool TransitionWidget::_paintEnabled = true;
- bool TransitionWidget::paintEnabled( void )
- { return _paintEnabled; }
-
- int TransitionWidget::_steps = 0;
-
- //________________________________________________
- TransitionWidget::TransitionWidget( QWidget* parent, int duration ):
- QWidget( parent ),
- _flags( None ),
- _animation( new Animation( duration, this ) ),
- _opacity( 0 )
- {
-
- // background flags
- setAttribute(Qt::WA_NoSystemBackground );
- setAutoFillBackground( false );
-
- // setup animation
- _animation.data()->setStartValue( 0 );
- _animation.data()->setEndValue( 1.0 );
- _animation.data()->setTargetObject( this );
- _animation.data()->setPropertyName( "opacity" );
-
- // setup connections
- connect( _animation.data(), SIGNAL(finished()), SIGNAL(finished()) );
-
- }
-
- //________________________________________________
- QPixmap TransitionWidget::grab( QWidget* widget, QRect rect )
- {
-
- // change rect
- if( !rect.isValid() ) rect = widget->rect();
- if( !rect.isValid() ) return QPixmap();
-
- // initialize pixmap
- QPixmap out( rect.size() );
- out.fill( Qt::transparent );
- _paintEnabled = false;
-
- if( testFlag( GrabFromWindow ) )
- {
-
- rect = rect.translated( widget->mapTo( widget->window(), widget->rect().topLeft() ) );
- widget = widget->window();
- out = QPixmap::grabWidget( widget, rect );
-
- } else {
-
- if( !testFlag( Transparent ) ) { grabBackground( out, widget, rect ); }
- grabWidget( out, widget, rect );
-
- }
-
- _paintEnabled = true;
-
- return out;
-
- }
-
- //________________________________________________
- void TransitionWidget::paintEvent( QPaintEvent* event )
- {
-
- // fully transparent case
- if( opacity() >= 1.0 && endPixmap().isNull() ) return;
- if( !_paintEnabled ) return;
-
- // get rect
- QRect rect = event->rect();
- if( !rect.isValid() ) rect = this->rect();
-
- // local pixmap
- const bool paintOnWidget( testFlag( PaintOnWidget ) && !testFlag( Transparent ) );
- if( !paintOnWidget )
- {
-
- if( _currentPixmap.isNull() || _currentPixmap.size() != size() )
- { _currentPixmap = QPixmap( size() ); }
-
- }
-
- // fill
- _currentPixmap.fill( Qt::transparent );
-
- // copy local pixmap to current
- {
-
- QPainter p;
-
- // draw end pixmap first, provided that opacity is small enough
- if( opacity() >= 0.004 && !_endPixmap.isNull() )
- {
-
- // faded endPixmap if parent target is transparent and opacity is
- if( opacity() <= 0.996 && testFlag( Transparent ) )
- {
-
- fade( _endPixmap, _currentPixmap, opacity(), rect );
- p.begin( &_currentPixmap );
- p.setClipRect( event->rect() );
-
- } else {
-
- if( paintOnWidget ) p.begin( this );
- else p.begin( &_currentPixmap );
- p.setClipRect( event->rect() );
- p.drawPixmap( QPoint(), _endPixmap );
-
- }
-
- } else {
-
- if( paintOnWidget ) p.begin( this );
- else p.begin( &_currentPixmap );
- p.setClipRect( event->rect() );
-
- }
-
- // draw fading start pixmap
- if( opacity() <= 0.996 && !_startPixmap.isNull() )
- {
- if( opacity() >= 0.004 )
- {
-
- fade( _startPixmap, _localStartPixmap, 1.0-opacity(), rect );
- p.drawPixmap( QPoint(), _localStartPixmap );
-
- } else p.drawPixmap( QPoint(), _startPixmap );
-
- }
-
- p.end();
- }
-
- // copy current pixmap on widget
- if( !paintOnWidget )
- {
- QPainter p( this );
- p.setClipRect( event->rect() );
- p.drawPixmap( QPoint(0,0), _currentPixmap );
- p.end();
- }
- }
-
- //________________________________________________
- void TransitionWidget::grabBackground( QPixmap& pixmap, QWidget* widget, QRect& rect ) const
- {
- if( !widget ) return;
-
- QWidgetList widgets;
- if( widget->autoFillBackground() )
- { widgets.push_back( widget ); }
-
- QWidget *parent(0);
-
- // get highest level parent
- for( parent = widget->parentWidget(); parent; parent = parent->parentWidget() )
- {
-
- if( !( parent->isVisible() && parent->rect().isValid() ) ) continue;
-
- // store in list
- widgets.push_back( parent );
-
- // stop at topLevel
- if( parent->isTopLevel() || parent->autoFillBackground() ) break;
-
- }
-
- if( !parent ) parent = widget;
-
- // painting
- QPainter p(&pixmap);
- p.setClipRect( rect );
- const QBrush backgroundBrush = parent->palette().brush( parent->backgroundRole());
- if( backgroundBrush.style() == Qt::TexturePattern)
- {
-
- p.drawTiledPixmap( rect, backgroundBrush.texture(), widget->mapTo( parent, rect.topLeft() ) );
-
- } else {
-
- p.fillRect( pixmap.rect(), backgroundBrush );
-
- }
-
- if( parent->isTopLevel() && parent->testAttribute(Qt::WA_StyledBackground))
- {
- QStyleOption option;
- option.initFrom(parent);
- option.rect = rect;
- option.rect.translate( widget->mapTo( parent, rect.topLeft() ) );
- p.translate(-option.rect.topLeft());
- parent->style()->drawPrimitive ( QStyle::PE_Widget, &option, &p, parent );
- }
-
- p.end();
-
- // draw all widgets in parent list
- // backward
- QPaintEvent event(rect);
- for( int i = widgets.size() - 1; i>=0; i-- )
- {
- QWidget* w = widgets.at(i);
- QPainter::setRedirected( w, &pixmap, widget->mapTo(w, rect.topLeft() ) );
- event = QPaintEvent(QRect( QPoint(), rect.size()));
- QCoreApplication::sendEvent(w, &event);
- QPainter::restoreRedirected(w);
- }
-
- }
-
- //________________________________________________
- void TransitionWidget::grabWidget( QPixmap& pixmap, QWidget* widget, QRect& rect ) const
- { widget->render( &pixmap, pixmap.rect().topLeft(), rect, QWidget::DrawChildren ); }
-
- //________________________________________________
- void TransitionWidget::fade( const QPixmap& source, QPixmap& target, qreal opacity, const QRect& rect ) const
- {
-
- if( target.isNull() || target.size() != size() )
- { target = QPixmap( size() ); }
-
- // erase target
- target.fill( Qt::transparent );
-
- // check opacity
- if( opacity*255 < 1 ) return;
-
- QPainter p( &target );
- p.setClipRect( rect );
-
- // draw pixmap
- p.drawPixmap( QPoint(0,0), source );
-
- // opacity mask (0.996 corresponds to 254/255)
- if( opacity <= 0.996 )
- {
- p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
- QColor color( Qt::black );
- color.setAlphaF( opacity );
- p.fillRect(rect, color );
- }
-
- p.end();
- return;
- }
-
-}
+++ /dev/null
-#ifndef oxygentransitionwidget_h
-#define oxygentransitionwidget_h
-//////////////////////////////////////////////////////////////////////////////
-// oxygentransitionwidget.h
-// stores event filters and maps widgets to transitions for transitions
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimation.h"
-
-#include <QtCore/QWeakPointer>
-#include <QtGui/QWidget>
-
-#include <cmath>
-
-namespace Oxygen
-{
-
- //! temporary widget used to perform smooth transition between one widget state and another
- class TransitionWidget: public QWidget
- {
-
- Q_OBJECT
-
- //! declare opacity property
- Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity )
-
- public:
-
- //! shortcut to painter
- typedef QWeakPointer<TransitionWidget> Pointer;
-
- //! constructor
- TransitionWidget( QWidget* parent, int duration );
-
- //! destructor
- virtual ~TransitionWidget( void )
- {}
-
- //!@name flags
- //@{
- enum Flag
- {
- None = 0,
- GrabFromWindow = 1<<0,
- Transparent = 1<<1,
- PaintOnWidget = 1<<2
- };
-
- Q_DECLARE_FLAGS(Flags, Flag)
-
- void setFlags( Flags value )
- { _flags = value; }
-
- void setFlag( Flag flag, bool value = true )
- {
- if( value ) _flags |= flag;
- else _flags &= (~flag);
- }
-
- bool testFlag( Flag flag ) const
- { return _flags.testFlag( flag ); }
-
- //@}
-
- //! duration
- void setDuration( int duration )
- {
- if( _animation )
- { _animation.data()->setDuration( duration ); }
- }
-
- //! duration
- int duration( void ) const
- { return ( _animation ) ? _animation.data()->duration() : 0; }
-
- //! steps
- static void setSteps( int value )
- { _steps = value; }
-
- //!@name opacity
- //@{
-
- virtual qreal opacity( void ) const
- { return _opacity; }
-
- virtual void setOpacity( qreal value )
- {
- value = digitize( value );
- if( _opacity == value ) return;
- _opacity = value;
- update();
- }
-
- //@}
-
- //@name pixmaps handling
- //@{
-
- //! start
- void resetStartPixmap( void )
- { setStartPixmap( QPixmap() ); }
-
- //! start
- void setStartPixmap( QPixmap pixmap )
- { _startPixmap = pixmap; }
-
- //! start
- const QPixmap& startPixmap( void ) const
- { return _startPixmap; }
-
- //! end
- void resetEndPixmap( void )
- { setEndPixmap( QPixmap() ); }
-
- //! end
- void setEndPixmap( QPixmap pixmap )
- {
- _endPixmap = pixmap;
- _currentPixmap = pixmap;
- }
-
- //! start
- const QPixmap& endPixmap( void ) const
- { return _endPixmap; }
-
- //! current
- const QPixmap& currentPixmap( void ) const
- { return _currentPixmap; }
-
- //@}
-
- //! grap pixmap
- QPixmap grab( QWidget* = 0, QRect = QRect() );
-
- //! true if animated
- virtual bool isAnimated( void ) const
- { return _animation.data()->isRunning(); }
-
- //! end animation
- virtual void endAnimation( void )
- { if( _animation.data()->isRunning() ) _animation.data()->stop(); }
-
- //! animate transition
- virtual void animate( void )
- {
- endAnimation();
- _animation.data()->start();
- }
-
- //! true if paint is enabled
- static bool paintEnabled( void );
-
- signals:
-
- //! emmitted when animation is finished/aborder
- void finished( void );
-
- protected:
-
- //! paint event
- virtual void paintEvent( QPaintEvent* );
-
- //! grab widget background
- /*!
- Background is not rendered properly using QWidget::render.
- Use home-made grabber instead. This is directly inspired from bespin.
- Copyright (C) 2007 Thomas Luebking <thomas.luebking@web.de>
- */
- virtual void grabBackground( QPixmap&, QWidget*, QRect& ) const;
-
- //! grab widget
- virtual void grabWidget( QPixmap&, QWidget*, QRect& ) const;
-
- //! fade pixmap
- virtual void fade( const QPixmap& source, QPixmap& target, qreal opacity, const QRect& ) const;
-
- //! apply step
- virtual qreal digitize( const qreal& value ) const
- {
- if( _steps > 0 ) return std::floor( value*_steps )/_steps;
- else return value;
- }
-
- private:
-
- //! Flags
- Flags _flags;
-
- //! paint enabled
- static bool _paintEnabled;
-
- //! internal transition animation
- Animation::Pointer _animation;
-
- //! animation starting pixmap
- QPixmap _startPixmap;
-
- //! animation starting pixmap
- QPixmap _localStartPixmap;
-
- //! animation starting pixmap
- QPixmap _endPixmap;
-
- //! current pixmap
- QPixmap _currentPixmap;
-
- //! current state opacity
- qreal _opacity;
-
- //! steps
- static int _steps;
-
- };
-
-}
-
-#endif
oxygenexceptionlist.cpp
oxygenfactory.cpp
oxygensizegrip.cpp
- oxygentitleanimationdata.cpp
)
kde4_add_kcfg_files(kwin_oxygen_SRCS oxygenconfiguration.kcfgc )
include_directories( ${KDEBASE_WORKSPACE_SOURCE_DIR}/libs/oxygen)
set(kwin_oxygen_config_PART_SRCS
- oxygenanimationconfigwidget.cpp
oxygenconfig.cpp
oxygenconfigwidget.cpp
oxygendetectwidget.cpp
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenanimationconfigwidget.cpp
-// animation configuration widget
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimationconfigwidget.h"
-#include "oxygenanimationconfigwidget.moc"
-#include "oxygenanimationconfigitem.h"
-#include "oxygengenericanimationconfigitem.h"
-
-#include <QButtonGroup>
-#include <QtGui/QHoverEvent>
-#include <QTextStream>
-#include <KDE/KLocalizedString>
-
-namespace Oxygen
-{
-
- //_______________________________________________
- AnimationConfigWidget::AnimationConfigWidget( QWidget* parent ):
- BaseAnimationConfigWidget( parent )
- {
-
- QGridLayout* layout( qobject_cast<QGridLayout*>( BaseAnimationConfigWidget::layout() ) );
-
- setupItem( layout, _buttonAnimations = new GenericAnimationConfigItem( this,
- i18n("Button mouseover transition"),
- i18n("Configure window buttons' mouseover highlight animation" ) ) );
-
- setupItem( layout, _titleAnimations = new GenericAnimationConfigItem( this,
- i18n("Title transitions" ),
- i18n("Configure fading transitions when window title is changed" ) ) );
-
- setupItem( layout, _shadowAnimations = new GenericAnimationConfigItem( this,
- i18n("Window active state change transitions" ),
- i18n("Configure fading between window shadow and glow when window's active state is changed" ) ) );
-
- setupItem( layout, _tabAnimations = new GenericAnimationConfigItem( this,
- i18n("Window grouping animations" ),
- i18n("Configure window titlebar animations when windows are grouped/ungrouped" ) ) );
-
- // add spacers to the first column, previous row to finalize layout
- layout->addItem( new QSpacerItem( 25, 0 ), _row-1, 0, 1, 1 );
-
- // add vertical spacer
- layout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ), _row, 1, 1, 1 );
- ++_row;
-
- connect( animationsEnabled(), SIGNAL(toggled(bool)), SLOT(updateChanged()) );
- foreach( AnimationConfigItem* item, findChildren<AnimationConfigItem*>() )
- {
- item->QWidget::setEnabled( false );
- connect( animationsEnabled(), SIGNAL(toggled(bool)), item, SLOT(setEnabled(bool)) );
- }
-
- }
-
- //_______________________________________________
- void AnimationConfigWidget::load( void )
- {
-
- // check configuration
- if( !_configuration ) return;
-
- animationsEnabled()->setChecked( _configuration->animationsEnabled() );
-
- _buttonAnimations->setEnabled( _configuration->buttonAnimationsEnabled() );
- _buttonAnimations->setDuration( _configuration->buttonAnimationsDuration() );
-
- _titleAnimations->setEnabled( _configuration->titleAnimationsEnabled() );
- _titleAnimations->setDuration( _configuration->titleAnimationsDuration() );
-
- _shadowAnimations->setEnabled( _configuration->shadowAnimationsEnabled() );
- _shadowAnimations->setDuration( _configuration->shadowAnimationsDuration() );
-
- _tabAnimations->setEnabled( _configuration->tabAnimationsEnabled() );
- _tabAnimations->setDuration( _configuration->tabAnimationsDuration() );
-
- setChanged( false );
-
- }
-
- //_______________________________________________
- void AnimationConfigWidget::save( void )
- {
-
- // check configuration
- if( !_configuration ) return;
-
- // save modifications
- _configuration->setAnimationsEnabled( animationsEnabled()->isChecked() );
-
- _configuration->setButtonAnimationsEnabled( _buttonAnimations->enabled() );
- _configuration->setButtonAnimationsDuration( _buttonAnimations->duration() );
-
- _configuration->setTitleAnimationsEnabled( _titleAnimations->enabled() );
- _configuration->setTitleAnimationsDuration( _titleAnimations->duration() );
-
- _configuration->setShadowAnimationsEnabled( _shadowAnimations->enabled() );
- _configuration->setShadowAnimationsDuration( _shadowAnimations->duration() );
-
- _configuration->setTabAnimationsEnabled( _tabAnimations->enabled() );
- _configuration->setTabAnimationsDuration( _tabAnimations->duration() );
-
- setChanged( false );
-
- }
-
- //_______________________________________________
- void AnimationConfigWidget::updateChanged( void )
- {
-
- // check configuration
- if( !_configuration ) return;
-
- // track modifications
- bool modified( false );
- if( animationsEnabled()->isChecked() != _configuration->animationsEnabled() ) modified = true;
- else if( _buttonAnimations->enabled() != _configuration->buttonAnimationsEnabled() ) modified = true;
- else if( _buttonAnimations->duration() != _configuration->buttonAnimationsDuration() ) modified = true;
-
- else if( _titleAnimations->enabled() != _configuration->titleAnimationsEnabled() ) modified = true;
- else if( _titleAnimations->duration() != _configuration->titleAnimationsDuration() ) modified = true;
-
- else if( _shadowAnimations->enabled() != _configuration->shadowAnimationsEnabled() ) modified = true;
- else if( _shadowAnimations->duration() != _configuration->shadowAnimationsDuration() ) modified = true;
-
- else if( _tabAnimations->enabled() != _configuration->tabAnimationsEnabled() ) modified = true;
- else if( _tabAnimations->duration() != _configuration->tabAnimationsDuration() ) modified = true;
-
- setChanged( modified );
-
- }
-
-}
+++ /dev/null
-#ifndef oxygenanimationconfigwidget_h
-#define oxygenanimationconfigwidget_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenanimationconfigwidget.h
-// animation configuration item
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "../oxygendecorationdefines.h"
-#include "oxygenbaseanimationconfigwidget.h"
-
-namespace Oxygen
-{
-
- // forward declaration
- class GenericAnimationConfigItem;
-
- //! container to configure animations individually
- class AnimationConfigWidget: public BaseAnimationConfigWidget
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit AnimationConfigWidget( QWidget* = 0 );
-
- //! destructor
- virtual ~AnimationConfigWidget( void )
- {}
-
- //! configuration
- void setConfiguration( ConfigurationPtr configuration )
- { _configuration = configuration; }
-
- public slots:
-
- //! read current configuration
- virtual void load( void );
-
- //! save current configuration
- virtual void save( void );
-
- protected slots:
-
- //! check whether configuration is changed and emit appropriate signal if yes
- virtual void updateChanged();
-
- private:
-
- //! local configuration, needed to handle I/O
- ConfigurationPtr _configuration;
-
- //!@name animations
- //@{
- GenericAnimationConfigItem* _buttonAnimations;
- GenericAnimationConfigItem* _titleAnimations;
- GenericAnimationConfigItem* _shadowAnimations;
- GenericAnimationConfigItem* _tabAnimations;
- //@}
-
- };
-
-}
-
-#endif
#include "oxygenconfig.h"
#include "oxygenconfig.moc"
-#include "oxygenanimationconfigwidget.h"
#include "oxygenconfiguration.h"
#include "oxygenutil.h"
#include "../oxygenexceptionlist.h"
{ delete _configWidget; }
//_______________________________________________________________________
- void Config::toggleExpertMode( bool value )
- { _configWidget->toggleExpertMode( value ); }
-
- //_______________________________________________________________________
void Config::load( void )
{
//! restore defaults
void defaults( void );
- //! toggle expert mode
- void toggleExpertMode( bool );
-
private slots:
//! update change state
//////////////////////////////////////////////////////////////////////////////
#include "oxygenconfigwidget.h"
-#include "oxygenanimationconfigwidget.h"
#include <kdeversion.h>
//_________________________________________________________
ConfigWidget::ConfigWidget( QWidget* parent ):
QWidget( parent ),
- _expertMode( false ),
- _animationConfigWidget(0),
_changed( false )
{
shadowConfigurations.append( ui.activeShadowConfiguration );
shadowConfigurations.append( ui.inactiveShadowConfiguration );
- // animation config widget
- _animationConfigWidget = new AnimationConfigWidget();
- _animationConfigWidget->installEventFilter( this );
-
- // expert mode
- ui._expertModeButton->setIcon( KIcon("configure") );
- toggleExpertModeInternal( false );
-
- // connections
- connect( ui._expertModeButton, SIGNAL(clicked()), SLOT(toggleExpertModeInternal()) );
- connect( _animationConfigWidget, SIGNAL(layoutChanged()), SLOT(updateLayout()) );
-
// track ui changes
connect( ui.titleAlignment, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( ui.buttonSize, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( shadowConfigurations[0], SIGNAL(changed(bool)), SLOT(updateChanged()) );
connect( shadowConfigurations[1], SIGNAL(changed(bool)), SLOT(updateChanged()) );
- // track animations changes
- connect( ui.animationsEnabled, SIGNAL(clicked()), SLOT(updateChanged()) );
- connect( _animationConfigWidget, SIGNAL(changed(bool)), SLOT(updateChanged()) );
-
}
//_________________________________________________________
void ConfigWidget::setConfiguration( ConfigurationPtr configuration )
{
_configuration = configuration;
- _animationConfigWidget->setConfiguration( configuration );
}
//_________________________________________________________
ui.separatorMode->setCurrentIndex( _configuration->separatorMode() );
ui.drawSizeGrip->setChecked( _configuration->drawSizeGrip() );
ui.titleOutline->setChecked( _configuration->drawTitleOutline() );
- ui.animationsEnabled->setChecked( _configuration->animationsEnabled() );
ui.narrowButtonSpacing->setChecked( _configuration->useNarrowButtonSpacing() );
ui.closeFromMenuButton->setChecked( _configuration->closeWindowFromMenuButton() );
setChanged( false );
-
- _animationConfigWidget->load();
-
}
//_________________________________________________________
setChanged( false );
- if( _expertMode ) _animationConfigWidget->save();
- else _configuration->setAnimationsEnabled( ui.animationsEnabled->isChecked() );
-
-
- }
-
- //_________________________________________________________
- void ConfigWidget::toggleExpertMode( bool value )
- {
- ui._expertModeContainer->hide();
- toggleExpertModeInternal( value );
- }
-
- //_________________________________________________________
- void ConfigWidget::toggleExpertModeInternal( bool value )
- {
-
- // store value
- _expertMode = value;
-
- // update button text
- ui._expertModeButton->setText( _expertMode ? i18n( "Hide Advanced Configuration Options" ):i18n( "Show Advanced Configuration Options" ) );
-
- // narrow button spacing
- ui.narrowButtonSpacing->setVisible( _expertMode );
-
- // size grip
- ui.drawSizeGrip->setVisible( _expertMode );
-
- // 'basic' animations enabled flag
- ui.animationsEnabled->setVisible( !_expertMode );
-
- // layout and animations
- if( _expertMode )
- {
-
- // add animationConfigWidget to tabbar if needed
- if( ui.tabWidget->indexOf( _animationConfigWidget ) < 0 )
- { ui.tabWidget->insertTab( 1, _animationConfigWidget, i18n( "Animations" ) ); }
-
- ui.shadowSpacer->changeSize(0,0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
-
- } else {
-
- ui.shadowSpacer->changeSize(0,0, QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
-
- if( int index = ui.tabWidget->indexOf( _animationConfigWidget ) >= 0 )
- { ui.tabWidget->removeTab( index ); }
-
- }
-
}
//__________________________________________________________________
void ConfigWidget::updateLayout( void )
{
- int delta = _animationConfigWidget->minimumSizeHint().height() - _animationConfigWidget->size().height();
- window()->setMinimumSize( QSize( window()->minimumSizeHint().width(), window()->size().height() + delta ) );
+ window()->setMinimumSize( QSize( window()->minimumSizeHint().width(), window()->size().height() ) );
}
else if( shadowConfigurations[0]->isChanged() ) modified = true;
else if( shadowConfigurations[1]->isChanged() ) modified = true;
- // animations
- else if( !_expertMode && ui.animationsEnabled->isChecked() != _configuration->animationsEnabled() ) modified = true;
- else if( _expertMode && _animationConfigWidget->isChanged() ) modified = true;
-
setChanged( modified );
}
namespace Oxygen
{
- class AnimationConfigWidget;
-
//_____________________________________________
class ConfigWidget: public QWidget
{
//! shadow configuration
QVector<ShadowConfigWidget*> shadowConfigurations;
- //! toggle expert mode
- void toggleExpertMode( bool );
-
//! event filter
virtual bool eventFilter( QObject*, QEvent* );
protected slots:
- //! toggle expert mode
- void toggleExpertModeInternal( void )
- { toggleExpertModeInternal( !_expertMode ); }
-
- //! toggle expert mode
- void toggleExpertModeInternal( bool );
-
//! update changed state
virtual void updateChanged();
//! internal exception
ConfigurationPtr _configuration;
- //! expert mode
- bool _expertMode;
-
- //! animation config (expert mode only)
- AnimationConfigWidget* _animationConfigWidget;
-
//! changed state
bool _changed;
</item>
</widget>
</item>
- <item row="4" column="0" colspan="4">
+ <item row="3" column="0" colspan="4">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</spacer>
</item>
- <item row="3" column="0" colspan="4">
- <widget class="QCheckBox" name="animationsEnabled">
- <property name="text">
- <string>Enable animations</string>
- </property>
- </widget>
- </item>
<item row="0" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
</widget>
</widget>
</item>
- <item>
- <widget class="QWidget" name="_expertModeContainer" native="true">
- <layout class="QGridLayout" name="gridLayout_5">
- <item row="0" column="1">
- <widget class="QPushButton" name="_expertModeButton">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="3">
- <widget class="QFrame" name="frame_2">
- <property name="frameShape">
- <enum>QFrame::HLine</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
</layout>
</widget>
<customwidgets>
<tabstop>frameBorder</tabstop>
<tabstop>titleAlignment</tabstop>
<tabstop>buttonSize</tabstop>
- <tabstop>animationsEnabled</tabstop>
- <tabstop>_expertModeButton</tabstop>
<tabstop>separatorMode</tabstop>
<tabstop>titleOutline</tabstop>
<tabstop>narrowButtonSpacing</tabstop>
_type(type),
_status( 0 ),
_forceInactive( false ),
- _glowAnimation( new Animation( 150, this ) ),
_glowIntensity(0)
{
setAutoFillBackground(false);
setCursor(Qt::ArrowCursor);
setToolTip(tip);
- // setup animation
- _glowAnimation->setStartValue( 0 );
- _glowAnimation->setEndValue( 1.0 );
- _glowAnimation->setTargetObject( this );
- _glowAnimation->setPropertyName( "glowIntensity" );
- _glowAnimation->setEasingCurve( QEasingCurve::InOutQuad );
-
// setup connections
reset(0);
//_______________________________________________
QColor Button::buttonDetailColor(const QPalette &palette) const
{
- if( _client.glowIsAnimated() && !_forceInactive && !_client.isForcedActive()) return KColorUtils::mix(
- buttonDetailColor( palette, false ),
- buttonDetailColor( palette, true ),
- _client.glowIntensity() );
- else return buttonDetailColor( palette, isActive() || _client.isForcedActive() );
+ return buttonDetailColor( palette, isActive() || _client.isForcedActive() );
}
//___________________________________________________
{ return (!_forceInactive) && _client.isActive(); }
//___________________________________________________
- bool Button::buttonAnimationsEnabled( void ) const
- { return _client.animationsEnabled() && _client.configuration()->buttonAnimationsEnabled(); }
-
- //___________________________________________________
QSize Button::sizeHint() const
{
unsigned int size( _client.buttonSize() );
//___________________________________________________
void Button::reset( unsigned long )
- { _glowAnimation->setDuration( _client.configuration()->buttonAnimationsDuration() ); }
+ { }
//___________________________________________________
void Button::paint( QPainter& painter )
// decide decoration color
QColor glow;
- if( isAnimated() || (_status&Hovered) )
+ if( (_status&Hovered) )
{
glow = isCloseButton() ?
_helper.viewNegativeTextBrush().brush(palette).color():
_helper.viewHoverBrush().brush(palette).color();
- if( isAnimated() )
- {
-
- color = KColorUtils::mix( color, glow, glowIntensity() );
- glow = _helper.alphaColor( glow, glowIntensity() );
-
- } else if( _status&Hovered ) color = glow;
+ if( _status&Hovered ) color = glow;
}
KCommonDecorationButton::enterEvent( event );
_status |= Hovered;
- if( buttonAnimationsEnabled() )
- {
-
- _glowAnimation->setDirection( Animation::Forward );
- if( !isAnimated() ) _glowAnimation->start();
-
- } else parentUpdate();
+ parentUpdate();
}
KCommonDecorationButton::leaveEvent( event );
- if( _status&Hovered && buttonAnimationsEnabled() )
- {
- _glowAnimation->setDirection( Animation::Backward );
- if( !isAnimated() ) _glowAnimation->start();
- }
-
_status &= ~Hovered;
parentUpdate();
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
-#include "oxygenanimation.h"
#include "oxygendecorationdefines.h"
#include "oxygendecohelper.h"
}
- //! true if animation is in progress
- bool isAnimated( void ) const
- { return _glowAnimation->isRunning(); }
-
//! true if button is active
bool isActive( void ) const;
- //! true if buttons hover are animated
- bool buttonAnimationsEnabled( void ) const;
-
//!@name button properties
//@{
//! true if button should be forced inactive
bool _forceInactive;
- //! glow animation
- //Animation::Pointer _glowAnimation;
- Animation* _glowAnimation;
-
//! glow intensity
qreal _glowIntensity;
KCommonDecorationUnstable(b, f),
_factory( f ),
_sizeGrip( 0 ),
- _glowAnimation( new Animation( 200, this ) ),
- _titleAnimationData( new TitleAnimationData( this ) ),
- _glowIntensity(0),
_initialized( false ),
_forceActive( false ),
_mouseButton( Qt::NoButton ),
widget()->setAutoFillBackground( false );
widget()->setAcceptDrops( true );
- // setup glow animation
- _glowAnimation->setStartValue( glowBias() );
- _glowAnimation->setEndValue( 1.0 );
- _glowAnimation->setTargetObject( this );
- _glowAnimation->setPropertyName( "glowIntensity" );
- _glowAnimation->setEasingCurve( QEasingCurve::InOutQuad );
- connect( _glowAnimation, SIGNAL(finished()), this, SLOT(clearForceActive()) );
-
- // title animation data
- _titleAnimationData->initialize();
- connect( _titleAnimationData, SIGNAL(pixmapsChanged()), SLOT(updateTitleRect()) );
-
- // lists
- connect( _itemData.animation().data(), SIGNAL(finished()), this, SLOT(clearTargetItem()) );
-
// in case of preview, one wants to make the label used
// for the central widget transparent. This allows one to have
// the correct background (with gradient) rendered
_configuration = _factory->configuration( *this );
- // glow animations
- _glowAnimation->setDuration( _configuration->shadowAnimationsDuration() );
-
- // title transitions
- _titleAnimationData->setDuration( _configuration->titleAnimationsDuration() );
-
- // tabs
- _itemData.setAnimationsEnabled( animationsEnabled() && _configuration->tabAnimationsEnabled() );
- _itemData.animation().data()->setDuration( _configuration->tabAnimationsDuration() );
-
- // reset title transitions
- _titleAnimationData->reset();
-
// should also update animations for buttons
resetButtons();
//_________________________________________________________
void Client::clearTargetItem( void )
{
-
- if( _itemData.animationType() == AnimationLeave )
- { _itemData.setDirty( true ); }
-
}
//_________________________________________________________
void Client::updateItemBoundingRects( bool alsoUpdate )
{
- // make sure items are not animated
- _itemData.animate( AnimationNone );
-
// maximum available space
const QRect titleRect( this->titleRect() );
//_________________________________________________________
QColor Client::titlebarTextColor(const QPalette &palette) const
{
- if( glowIsAnimated() ) return KColorUtils::mix(
- titlebarTextColor( palette, false ),
- titlebarTextColor( palette, true ),
- glowIntensity() );
- else return titlebarTextColor( palette, isActive() );
+ return titlebarTextColor( palette, isActive() );
}
//_________________________________________________________
// base color
QColor color( palette.window().color() );
- // add alpha channel
- if( _itemData.count() == 1 && glowIsAnimated() )
- { color = helper().alphaColor( color, glowIntensity() ); }
-
// title height
const int titleHeight( layoutMetric( LM_TitleEdgeTop ) + layoutMetric( LM_TitleEdgeBottom ) + layoutMetric( LM_TitleHeight ) );
// make titlebar background darker for tabbed, non-outline window
- if( ( tabCount() >= 2 || _itemData.isAnimated() ) && !(_configuration->drawTitleOutline() && isActive() ) )
+ if( tabCount() >= 2 && !(_configuration->drawTitleOutline() && isActive() ) )
{
const QPoint topLeft( r.topLeft()-position );
// adjustements to cope with shadow size and outline border.
rect.adjust( -shadowSize, 0, shadowSize-1, 0 );
- if( _configuration->drawTitleOutline() && ( isActive() || glowIsAnimated() ) && !isMaximized() )
+ if( _configuration->drawTitleOutline() && isActive() && !isMaximized() )
{
if( _configuration->frameBorder() == Configuration::BorderTiny ) rect.adjust( 1, 0, -1, 0 );
else if( _configuration->frameBorder() > Configuration::BorderTiny ) rect.adjust( HFRAMESIZE-1, 0, -HFRAMESIZE+1, 0 );
}
- if( _configuration->drawTitleOutline() && ( isActive() || glowIsAnimated() ) )
+ if( _configuration->drawTitleOutline() && isActive() )
{
// save old hints and turn off anti-aliasing
// set color
QColor local( color );
- if( glowIsAnimated() && _configuration->separatorMode() != Configuration::SeparatorAlways )
- { local = helper().alphaColor( color, glowIntensity() ); }
// render
helper().drawSeparator( painter, QRect(r.top(), titleTop+titleHeight-1.5, r.width(), 2).translated( -position ), local, Qt::Horizontal);
const QRect adjustedRect( rect.adjusted(offset, voffset, -offset, shadowSize) );
QColor color( palette.color( widget()->backgroundRole() ) );
- // add alpha channel
- if( _itemData.count() == 1 && glowIsAnimated() )
- { color = helper().alphaColor( color, glowIntensity() ); }
-
// render slab
helper().slab( color, 0, shadowSize )->render( adjustedRect, painter, TileSet::Tiles(TileSet::Top|TileSet::Left|TileSet::Right) );
void Client::renderTitleText( QPainter* painter, const QRect& rect, const QColor& color, const QColor& contrast ) const
{
- if( !_titleAnimationData->isValid() )
- {
- // contrast pixmap
- _titleAnimationData->reset(
- rect,
- renderTitleText( rect, caption(), color ),
- renderTitleText( rect, caption(), contrast ) );
- }
-
- if( _titleAnimationData->isDirty() )
- {
-
- // clear dirty flags
- _titleAnimationData->setDirty( false );
-
- // finish current animation if running
- if( _titleAnimationData->isAnimated() )
- { _titleAnimationData->finishAnimation(); }
-
- if( !_titleAnimationData->isLocked() )
- {
-
- // set pixmaps
- _titleAnimationData->setPixmaps(
- rect,
- renderTitleText( rect, caption(), color ),
- renderTitleText( rect, caption(), contrast ) );
-
- _titleAnimationData->startAnimation();
- renderTitleText( painter, rect, color, contrast );
-
- } else if( !caption().isEmpty() ) {
-
- renderTitleText( painter, rect, caption(), color, contrast );
-
- }
-
- // lock animations (this must be done whether or not
- // animation was actually started, in order to extend locking
- // every time title get changed too rapidly
- _titleAnimationData->lockAnimations();
-
- } else if( _titleAnimationData->isAnimated() ) {
-
- if( isMaximized() ) painter->translate( 0, 2 );
- if( !_titleAnimationData->contrastPixmap().isNull() )
- {
- painter->translate( 0, 1 );
- painter->drawPixmap( rect.topLeft(), _titleAnimationData->contrastPixmap() );
- painter->translate( 0, -1 );
- }
-
- painter->drawPixmap( rect.topLeft(), _titleAnimationData->pixmap() );
-
- if( isMaximized() ) painter->translate( 0, -2 );
-
- } else if( !caption().isEmpty() ) {
+ if( !caption().isEmpty() ) {
renderTitleText( painter, rect, caption(), color, contrast );
}
QRect textRect( item._boundingRect.adjusted( 0, layoutMetric( LM_TitleEdgeTop )-1, 0, -1 ) );
// add extra space needed for title outline
- if( itemCount > 1 || _itemData.isAnimated() )
+ if( itemCount > 1 )
{ textRect.adjust( layoutMetric( LM_TitleBorderLeft ), 0, -layoutMetric(LM_TitleBorderRight), 0 ); }
// add extra space for the button
// no title outline if the window caption is empty
if( !caption.trimmed().isEmpty() )
{
- if( _itemData.isAnimated() ) {
-
- renderTitleOutline( painter, item._boundingRect, palette );
-
- } else if( (isActive()||glowIsAnimated()) && _configuration->drawTitleOutline() ) {
+ if( isActive() && _configuration->drawTitleOutline() ) {
// adjusts boundingRect accordingly
QRect boundingRect( item._boundingRect );
//_______________________________________________________________________
void Client::renderTargetRect( QPainter* p, const QPalette& palette )
{
- if( _itemData.targetRect().isNull() || _itemData.isAnimationRunning() ) return;
+ if( _itemData.targetRect().isNull() ) return;
const QColor color = palette.color(QPalette::Highlight);
p->setPen(KColorUtils::mix(color, palette.color(QPalette::Active, QPalette::WindowText)));
KCommonDecorationUnstable::activeChange();
_itemData.setDirty( true );
- // reset animation
- if( shadowAnimationsEnabled() )
- {
- _glowAnimation->setDirection( isActive() ? Animation::Forward : Animation::Backward );
- if(!glowIsAnimated()) { _glowAnimation->start(); }
- }
-
// update size grip so that it gets the right color
// also make sure it is remaped to from z stack,
// unless hidden
KCommonDecorationUnstable::captionChange();
_itemData.setDirty( true );
- if( titleAnimationsEnabled() )
- { _titleAnimationData->setDirty( true ); }
}
if( _configuration->drawTitleOutline() )
{
- if( glowIsAnimated() && !isForcedActive() )
- {
-
- const QColor inactiveColor( backgroundColor( widget, palette, false ) );
- const QColor activeColor( backgroundColor( widget, palette, true ) );
- const QColor mixed( KColorUtils::mix( inactiveColor, activeColor, glowIntensity() ) );
- palette.setColor( QPalette::Window, mixed );
- palette.setColor( QPalette::Button, mixed );
-
- } else if( isActive() || isForcedActive() ) {
+ if( isActive() || isForcedActive() ) {
const QColor color = options()->color( KDecorationDefines::ColorTitleBar, true );
palette.setColor( QPalette::Window, color );
// prepare item data updates
_itemData.setDirty( true );
- // mark title animation as dirty
- if( event->oldSize().width() != event->size().width() )
- { _titleAnimationData->setDirty( true ); }
-
// resize backing store pixmap
if( !compositingActive() )
{ _pixmap = QPixmap( event->size() ); }
TileSet *tileSet( 0 );
const ShadowCache::Key key( this->key() );
- if( shadowCache().isEnabled( QPalette::Active ) && glowIsAnimated() && !isForcedActive() )
- {
-
- tileSet = shadowCache().tileSet( key, glowIntensity() );
-
- } else {
-
- tileSet = shadowCache().tileSet( key );
-
- }
+ tileSet = shadowCache().tileSet( key );
tileSet->render( frame, &painter, TileSet::Ring);
renderTargetRect( &painter, widget()->palette() );
// separator
- if( itemCount == 1 && !_itemData.isAnimated() && drawSeparator() )
+ if( itemCount == 1 && drawSeparator() )
{ renderSeparator(&painter, frame, widget(), color ); }
}
const int clickedIndex( tabIndexAt( point ) );
if( clickedIndex < 0 ) return false;
- _titleAnimationData->reset();
-
QDrag *drag = new QDrag( widget() );
QMimeData *groupData = new QMimeData();
groupData->setData( tabDragMimeType(), QString().setNum( tabId(clickedIndex) ).toAscii() );
// accept event
event->acceptProposedAction();
- // animate
- if( event->source() != widget() )
- {
-
- _itemData.animate( AnimationEnter, tabIndexAt( event->pos(), true ) );
-
- } else if( _itemData.count() > 1 ) {
-
- _itemData.animate( AnimationEnter|AnimationSameTarget, tabIndexAt( event->pos(), true ) );
-
- }
-
return true;
}
bool Client::dragLeaveEvent( QDragLeaveEvent* )
{
- if( _itemData.animationType() & AnimationSameTarget )
- {
-
- if( _dragStartTimer.isActive() ) _dragStartTimer.stop();
- _itemData.animate( AnimationLeave|AnimationSameTarget, _sourceItem );
-
- } else if( _itemData.isAnimated() ) {
-
- _itemData.animate( AnimationLeave );
-
- }
-
return true;
}
// check format
if( !event->mimeData()->hasFormat( tabDragMimeType() ) ) return false;
- // animate
- if( event->source() != widget() )
- {
-
- _itemData.animate( AnimationMove, tabIndexAt( event->pos(), true ) );
-
- } else if( _itemData.count() > 1 ) {
-
- if( _dragStartTimer.isActive() ) _dragStartTimer.stop();
- _itemData.animate( AnimationMove|AnimationSameTarget, tabIndexAt( event->pos(), true ) );
-
- }
-
return false;
}
{
const QPoint point = event->pos();
- _itemData.animate( AnimationNone );
const QMimeData *groupData = event->mimeData();
if( !groupData->hasFormat( tabDragMimeType() ) ) return false;
// update title
if( widget() == event->source() ) updateTitleRect();
- _titleAnimationData->reset();
return true;
}
_dragStartTimer.stop();
- // do nothing if there is only one tab
- if( _itemData.count() > 1 )
- {
- _itemData.animate( AnimationMove|AnimationSameTarget, _sourceItem );
- _itemData.animate( AnimationLeave|AnimationSameTarget, _sourceItem );
- }
-
}
//_____________________________________________________________
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
-#include "oxygenanimation.h"
#include "oxygenclientgroupitemdata.h"
#include "oxygenconfiguration.h"
#include "oxygendecohelper.h"
#include "oxygenfactory.h"
#include "oxygenshadowcache.h"
-#include "oxygentitleanimationdata.h"
#include <kcommondecoration.h>
#include <QBasicTimer>
Q_OBJECT
- //! declare glow intensity property
- Q_PROPERTY( qreal glowIntensity READ glowIntensityUnbiased WRITE setGlowIntensity )
-
public:
//! constructor
virtual bool isMaximized( void ) const
{ return maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows(); }
- //! true if animations are used
- bool animationsEnabled( void ) const
- { return _configuration->animationsEnabled(); }
-
- //! true if glow is animated
- bool glowIsAnimated( void ) const
- { return _glowAnimation->isRunning(); }
-
//! true when decoration is forced active
bool isForcedActive( void ) const
{ return _forceActive && tabCount() > 1; }
return true;
case Configuration::SeparatorActive:
- return ( glowIsAnimated() || isActive() );
+ return ( isActive() );
default:
case Configuration::SeparatorNever:
Factory::ConfigurationPtr configuration( void ) const
{ return _configuration; }
- //!@name glow animation
- //@{
-
- void setGlowIntensity( qreal value )
- {
- if( _glowIntensity == value ) return;
- _glowIntensity = value;
- widget()->update();
- }
-
- //! unbiased glow intensity
- qreal glowIntensityUnbiased( void ) const
- { return _glowIntensity; }
-
- //! glow bias
- static qreal glowBias( void )
- { return 0.2; }
-
- //! true (biased) intensity
- /*! this is needed to have glow go from either 0.2->1 or 0.8->0 depending on the animation direction */
- qreal glowIntensity( void ) const
- { return _glowAnimation->direction() == Animation::Forward ? _glowIntensity : _glowIntensity-glowBias(); }
-
- //@}
-
//! helper class
DecoHelper& helper( void ) const
{ return _factory->helper(); }
//! return pixmap corresponding to a given tab, for dragging
QPixmap itemDragPixmap( int, QRect, bool = false );
- //! return true when activity change are animated
- bool shadowAnimationsEnabled( void ) const
- { return ( animationsEnabled() && _configuration->shadowAnimationsEnabled() && !isPreview() ); }
-
- //! return true when activity change are animated
- bool titleAnimationsEnabled( void ) const
- {
- return
- animationsEnabled() &&
- _configuration->titleAnimationsEnabled() &&
- !_configuration->drawTitleOutline() &&
- !hideTitleBar() &&
- !isPreview();
- }
-
//! true if some title outline is rendered
bool hasTitleOutline( void ) const
{
return
tabCount() >= 2 ||
- _itemData.isAnimated() ||
- ( (isActive()||glowIsAnimated()) && _configuration->drawTitleOutline() );
+ ( isActive() && _configuration->drawTitleOutline() );
}
//! calculate mask
//! configuration
Factory::ConfigurationPtr _configuration;
- //! glow animation
- Animation* _glowAnimation;
-
- //! title animation data
- TitleAnimationData* _titleAnimationData;
-
- //! glow intensity
- qreal _glowIntensity;
-
//! true when initialized
bool _initialized;
QList<ClientGroupItemData>(),
_client( *parent ),
_dirty( false ),
- animationsEnabled_( true ),
- _animation( new Animation( 150, this ) ),
- animationType_( AnimationNone ),
- progress_(0),
draggedItem_( NoItem ),
targetItem_( NoItem )
{
- // setup animation
- animation().data()->setStartValue( 0 );
- animation().data()->setEndValue( 1.0 );
- animation().data()->setTargetObject( this );
- animation().data()->setPropertyName( "progress" );
-
}
//________________________________________________________________
}
//____________________________________________________________________________
- void ClientGroupItemDataList::animate( AnimationTypes type, int target )
- {
-
- // store animation type
- animationType_ = type;
-
- if( type == AnimationNone )
- {
-
- if( isAnimationRunning() ) animation().data()->stop();
- targetItem_ = NoItem;
- draggedItem_ = NoItem;
- targetRect_ = QRect();
-
- } else if( type & (AnimationEnter|AnimationMove ) ) {
-
- // store dragged item
- bool animate( true );
-
- if( (type&AnimationSameTarget) && draggedItem_ == NoItem )
- {
-
- animate = false;
- draggedItem_ = target;
-
- } else if( (type&AnimationMove) && targetItem_ == target ) return;
-
- // check animation state
- if( isAnimationRunning() ) animation().data()->stop();
-
- targetItem_ = target;
- targetRect_ = QRect();
- QRect titleRect( _client.titleRect() );
- int left( titleRect.left() );
- int width = (type&AnimationSameTarget) ?
- titleRect.width()/count():
- titleRect.width()/(count()+1);
-
- if( (type&AnimationSameTarget) && draggedItem_ < target )
- {
- target++;
- if( target >= count() ) target = NoItem;
- }
-
- // loop over items and update bounding rects
- for( int index = 0; index < count(); index++ )
- {
-
- ClientGroupItemData& item( ClientGroupItemDataList::operator[](index) );
- if( index == target )
- {
- targetRect_ = item._refBoundingRect;
- targetRect_.setLeft( left );
- targetRect_.setWidth( width );
- left+=width;
- }
-
- item._startBoundingRect = item._boundingRect;
- item._endBoundingRect = item._refBoundingRect;
- item._endBoundingRect.setLeft( left );
-
- if( (type&AnimationSameTarget) && index == draggedItem_ )
- {
-
- item._endBoundingRect.setWidth( 0 );
-
- } else {
-
- item._endBoundingRect.setWidth( width );
- left+=width;
-
- }
-
- }
-
- if( targetRect_.isNull() )
- {
- targetRect_ = back()._refBoundingRect;
- targetRect_.setLeft( left );
- targetRect_.setWidth( width );
- }
-
- if( animate )
- {
-
- if( animationsEnabled() ) animation().data()->start();
- else {
-
- // change progress to maximum
- progress_ = 1;
- updateBoundingRects();
-
- }
-
- } else {
-
- for( int index = 0; index < count(); index++ )
- {
- ClientGroupItemData& item( ClientGroupItemDataList::operator[](index) );
- item._boundingRect = item._endBoundingRect;
- }
-
- updateButtons( true );
-
- }
-
- } else if( type & AnimationLeave ) {
-
- // stop animation state
- if( isAnimationRunning() ) animation().data()->stop();
-
- // reset target
- targetItem_ = NoItem;
- targetRect_ = QRect();
-
- if( type & AnimationSameTarget )
- {
-
- // store dragged item
- draggedItem_ = target;
-
- // do nothing if only one item
- if( count() <= 1 ) return;
-
- QRect titleRect( _client.titleRect() );
- int left( titleRect.left() );
- int width = titleRect.width()/(count()-1);
-
- // loop over items and update bounding rects
- for( int index = 0; index < count(); index++ )
- {
-
- ClientGroupItemData& item( ClientGroupItemDataList::operator[](index) );
- item._startBoundingRect = item._boundingRect;
- item._endBoundingRect = item._refBoundingRect;
- item._endBoundingRect.setLeft( left );
- if( index != target )
- {
-
- if( count() <= 2 )
- {
-
- item._endBoundingRect = _client.defaultTitleRect( _client.tabId(index) == _client.currentTabId() );
-
- } else {
-
-
- item._endBoundingRect.setWidth( width );
- left+=width;
-
- }
-
- } else {
-
- item._endBoundingRect.setWidth( 0 );
-
- }
-
- }
-
- } else {
-
- // loop over items and update bounding rects
- for( int index = 0; index < count(); index++ )
- {
- ClientGroupItemData& item( ClientGroupItemDataList::operator[](index) );
- item._startBoundingRect = item._boundingRect;
- item._endBoundingRect = item._refBoundingRect;
- }
-
- }
-
- if( animationsEnabled() ) animation().data()->start();
- else {
-
- // change progress to maximum
- progress_ = 1;
- updateBoundingRects();
-
- }
-
- }
-
- return;
-
- }
-
- //____________________________________________________________________________
void ClientGroupItemDataList::updateButtonActivity( long visibleItem ) const
{
const ClientGroupItemData& item( at(index) );
if( !item._closeButton ) continue;
- if( (!item._boundingRect.isValid()) || ((animationType_ & AnimationSameTarget)&&count()<=2 ) )
+ if( (!item._boundingRect.isValid()) || count()<=2 )
{
item._closeButton.data()->hide();
void ClientGroupItemDataList::updateBoundingRects( bool alsoUpdate )
{
- qreal ratio( progress() );
for( iterator iter = begin(); iter != end(); ++iter )
{
} else {
- iter->_boundingRect.setLeft( (1.0-ratio)*iter->_startBoundingRect.left() + ratio*iter->_endBoundingRect.left() );
+ iter->_boundingRect.setLeft( (1.0)*iter->_startBoundingRect.left() *iter->_endBoundingRect.left() );
}
} else {
- iter->_boundingRect.setRight( (1.0-ratio)*iter->_startBoundingRect.right() + ratio*iter->_endBoundingRect.right() );
+ iter->_boundingRect.setRight( (1.0)*iter->_startBoundingRect.right() *iter->_endBoundingRect.right() );
}
//////////////////////////////////////////////////////////////////////////////
#include "oxygenbutton.h"
-#include "oxygenanimation.h"
#include <QList>
#include <QWeakPointer>
class Client;
- //! animation type
- enum AnimationType {
- AnimationNone = 0,
- AnimationEnter = 1<<0,
- AnimationMove = 1<<1,
- AnimationLeave = 1<<2,
- AnimationSameTarget = 1<<3
- };
-
- Q_DECLARE_FLAGS(AnimationTypes, AnimationType)
-
//! tab data
class ClientGroupItemData
{
Q_OBJECT
- //! declare animation progress property
- Q_PROPERTY( qreal progress READ progress WRITE setProgress )
-
public:
//! invalid item index
bool isDirty( void ) const
{ return _dirty; }
- //! enable animations
- void setAnimationsEnabled( bool value )
- { animationsEnabled_ = value; }
-
- //! animations enabled
- bool animationsEnabled( void ) const
- { return animationsEnabled_; }
-
- //! true if being animated
- bool isAnimated( void ) const
- { return animationType_ != AnimationNone; }
-
- //! animation type
- AnimationTypes animationType( void ) const
- { return animationType_; }
-
//! return item index matching QPoint, or -1 if none
int itemAt( const QPoint&, bool ) const;
bool isTarget( int index ) const
{ return index == targetItem_; }
- //! start animation
- /* might need to add the side of the target here */
- void animate( AnimationTypes, int = NoItem );
-
- //! true if animation is in progress
- bool isAnimationRunning( void ) const
- { return animation().data()->isRunning(); }
-
//! update button activity
void updateButtonActivity( long visibleItem ) const;
const QRect& targetRect( void ) const
{ return targetRect_; }
- //!@name animation progress
- //@{
-
- //! return animation object
- virtual const Animation::Pointer& animation() const
- { return _animation; }
-
- void setProgress( qreal value )
- {
- if( progress_ == value ) return;
- progress_ = value;
- updateBoundingRects();
- }
-
- qreal progress( void ) const
- { return progress_; }
-
- //@}
-
protected:
//! update bounding rects
/* used to trigger update at next paintEvent */
bool _dirty;
- //! true if animations are enabled
- bool animationsEnabled_;
-
- //! animation
- Animation::Pointer _animation;
-
- //! last animation type
- AnimationTypes animationType_;
-
- //! animation progress
- qreal progress_;
-
//! dragged item
int draggedItem_;
};
- Q_DECLARE_OPERATORS_FOR_FLAGS(Oxygen::AnimationTypes)
-
}
#endif
<default>true</default>
</entry>
- <!-- animations -->
- <entry name="AnimationsEnabled" type = "Bool">
- <default>false</default>
- </entry>
-
- <entry name="ButtonAnimationsEnabled" type = "Bool">
- <default>true</default>
- </entry>
-
- <entry name="TitleAnimationsEnabled" type = "Bool">
- <default>true</default>
- </entry>
-
- <entry name="ShadowAnimationsEnabled" type = "Bool">
- <default>true</default>
- </entry>
-
- <entry name="TabAnimationsEnabled" type = "Bool">
- <default>true</default>
- </entry>
-
- <entry name="ButtonAnimationsDuration" type = "Int">
- <default>150</default>
- </entry>
-
- <entry name="TitleAnimationsDuration" type = "Int">
- <default>150</default>
- </entry>
-
- <entry name="ShadowAnimationsDuration" type = "Int">
- <default>150</default>
- </entry>
-
- <entry name="TabAnimationsDuration" type = "Int">
- <default>150</default>
- </entry>
-
<!-- exceptions -->
<entry name="ExceptionType" type="Enum">
<choices>
// read shadowCache configuration
_shadowCache.readConfig();
- _shadowCache.setAnimationsDuration( _defaultConfiguration->shadowAnimationsDuration() );
// background pixmap
{
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygentitleanimationdata.h
-// handles transition when window title is changed
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygentitleanimationdata.h"
-#include "oxygentitleanimationdata.moc"
-
-#include <QtGui/QPainter>
-
-namespace Oxygen
-{
-
- // use 300 milliseconds for animation lock
- const int TitleAnimationData::_lockTime = 300;
-
- //_________________________________________________________
- TitleAnimationData::TitleAnimationData( QObject* parent ):
- QObject( parent ),
- _dirty( false ),
- _animation( new Animation( 200, this ) ),
- _opacity(0)
- {}
-
- //_________________________________________________________
- void TitleAnimationData::initialize( void )
- {
-
- // setup title animation
- animation().data()->setStartValue( 0 );
- animation().data()->setEndValue( 1 );
- animation().data()->setTargetObject( this );
- animation().data()->setPropertyName( "opacity" );
- animation().data()->setEasingCurve( QEasingCurve::InOutQuad );
-
- }
-
-
- //_________________________________________________________
- void TitleAnimationData::setPixmaps( QRect rect, QPixmap pixmap, QPixmap contrast )
- {
-
- // stop animation
- if( isAnimated() ) animation().data()->stop();
-
- // update pixmaps
- _contrastPixmap.initialize( rect, contrast );
- _pixmap.initialize( rect, pixmap );
-
- setOpacity(0);
- updatePixmaps();
-
- }
-
- //_________________________________________________________
- void TitleAnimationData::updatePixmaps( void )
- {
- _contrastPixmap.blend( opacity() );
- _pixmap.blend( opacity() );
- emit pixmapsChanged();
- }
-
- //_________________________________________________________
- void TitleAnimationData::timerEvent( QTimerEvent* e )
- {
-
- if( e->timerId() != _animationLockTimer.timerId() )
- { return QObject::timerEvent( e ); }
-
- // unlock
- unlockAnimations();
-
- if( !isAnimated() )
- {
- // triggers pixmap updates
- reset();
- emit pixmapsChanged();
- }
-
- }
-
- //_________________________________________________________
- void TitleAnimationData::BlendedPixmap::blend( qreal opacity )
- {
-
- _currentPixmap = QPixmap( _endRect.size() );
- _currentPixmap.fill( Qt::transparent );
-
- QPainter painter( &_currentPixmap );
- if( opacity < 1 && !_startPixmap.isNull() )
- { painter.drawPixmap( _startRect.topLeft() - _endRect.topLeft(), fade( _startPixmap, 1.0 - opacity ) ); }
-
- if( opacity > 0 && !_endPixmap.isNull() )
- { painter.drawPixmap( QPoint(0,0), fade( _endPixmap, opacity ) ); }
-
- painter.end();
- return;
-
- }
-
- //_________________________________________________________
- QPixmap TitleAnimationData::BlendedPixmap::fade( QPixmap source, qreal opacity ) const
- {
-
- if( source.isNull() ) return QPixmap();
-
- QPixmap out( source.size() );
- out.fill( Qt::transparent );
-
- // do nothing if opacity is too small
- if( opacity*255 < 1 ) return out;
-
- // draw pixmap
- QPainter p( &out );
- p.drawPixmap( QPoint(0,0), source );
-
- // opacity mask
- if( opacity*255 <= 254 )
- {
- p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
- QColor color( Qt::black );
- color.setAlphaF( opacity );
- p.fillRect(out.rect(), color );
- }
-
- p.end();
- return out;
-
- }
-
-}
+++ /dev/null
-#ifndef oxygentitleanimationdata_h
-#define oxygentitleanimationdata_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygentitleanimationdata.h
-// handles transition when window title is changed
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimation.h"
-
-#include <cassert>
-#include <QObject>
-#include <QWeakPointer>
-#include <QBasicTimer>
-#include <QTimerEvent>
-#include <QtGui/QPixmap>
-
-
-namespace Oxygen
-{
-
- class TitleAnimationData: public QObject
- {
-
- Q_OBJECT
-
- //! declare title opacity
- Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity )
-
- public:
-
- typedef QWeakPointer<TitleAnimationData> Pointer;
-
- //! constructor
- explicit TitleAnimationData( QObject* );
-
- //! reset
- void reset( void )
- {
- setOpacity(0);
- _contrastPixmap.reset();
- _pixmap.reset();
- }
-
- //! initialize
- void initialize( void );
-
- // reset
- void reset( QRect rect, QPixmap pixmap, QPixmap contrast )
- {
- setOpacity(0);
- _contrastPixmap.reset( rect, contrast );
- _pixmap.reset( rect, pixmap );
- }
-
- //! set pixmaps
- void setPixmaps( QRect, QPixmap pixmap, QPixmap contrast );
-
- //! duration
- void setDuration( int duration )
- {
- assert( animation() );
- animation().data()->setDuration( duration );
- }
-
- //! retrieve contrast pixmap
- QPixmap contrastPixmap( void ) const
- { return _contrastPixmap.currentPixmap(); }
-
- //! pixmap
- QPixmap pixmap( void ) const
- { return _pixmap.currentPixmap(); }
-
- //!@name animation
- //@{
-
- //! returns true if animations are locked
- bool isLocked( void ) const
- { return _animationLockTimer.isActive(); }
-
- //! returns true if title transition animation is currently running
- bool isAnimated( void ) const
- { return animation().data()->isRunning(); }
-
- //! start lock animation timer
- void lockAnimations( void )
- { _animationLockTimer.start( _lockTime, this ); }
-
- //! start lock animation timer
- void unlockAnimations( void )
- { _animationLockTimer.stop(); }
-
- //! start title transition animation
- void startAnimation( void )
- {
- assert( !isAnimated() );
- animation().data()->start();
- }
-
- //! finish title transition animation
- void finishAnimation( void )
- {
- assert( isAnimated() );
- animation().data()->stop();
- }
-
- //@}
-
- //!@name opacity
- //@{
-
- qreal opacity( void ) const
- { return _opacity; }
-
- void setOpacity( qreal value )
- {
- if( _opacity == value ) return;
- _opacity = value;
- updatePixmaps();
- }
-
- //@}
-
- //! validity
- bool isValid( void ) const
- { return _pixmap.isValid(); }
-
- //! dirty flag
- void setDirty( bool value )
- { _dirty = value; }
-
- //! dirty flag
- bool isDirty( void ) const
- { return _dirty; }
-
- signals:
-
- void pixmapsChanged( void );
-
- protected:
-
- //! update pixmaps
- virtual void updatePixmaps( void );
-
- //! timer event
- void timerEvent( QTimerEvent* );
-
- //! animation object
- const Animation::Pointer& animation( void ) const
- { return _animation; }
-
- private:
-
- //! used to blend pixmap
- class BlendedPixmap
- {
-
- public:
-
- // reset everything
- void reset( void )
- {
- _startRect = _endRect = QRect();
- _startPixmap = _endPixmap = _currentPixmap = QPixmap();
- }
-
- //! reset
- void reset( const QRect& rect, QPixmap pixmap )
- {
- _startRect = _endRect = rect;
- _startPixmap = _endPixmap = _currentPixmap = pixmap;
- }
-
- // update pixmaps
- void initialize( const QRect& rect, QPixmap pixmap )
- {
- _startRect = _endRect;
- _endRect = rect;
- _startPixmap = _currentPixmap;
- _endPixmap = pixmap;
- }
-
- //! update currentPixmap by blending start and end pixmap
- void blend( qreal opacity );
-
- //! current pixmap
- QPixmap currentPixmap( void ) const
- { return _currentPixmap; }
-
- //! validity
- bool isValid( void ) const
- { return !(_endRect.isNull() || _endPixmap.isNull() ); }
-
- protected:
-
- // fade pixmap by some amount
- QPixmap fade( QPixmap, qreal ) const;
-
- private:
-
- //! animation starting pixmap
- QPixmap _startPixmap;
-
- //! animation ending pixmap
- QPixmap _endPixmap;
-
- //! animation current pixmap
- QPixmap _currentPixmap;
-
- QRect _startRect;
- QRect _endRect;
-
- };
-
- bool _dirty;
-
- BlendedPixmap _contrastPixmap;
- BlendedPixmap _pixmap;
-
- //! lock time (milliseconds
- static const int _lockTime;
-
- //! timer used to disable animations when triggered too early
- QBasicTimer _animationLockTimer;
-
- //! title animation
- Animation::Pointer _animation;
-
- //! title opacity
- qreal _opacity;
-
- };
-
-
-}
-
-#endif
set(oxygenstyle_LIB_SRCS
- oxygenanimation.cpp
oxygenhelper.cpp
oxygenitemmodel.cpp
oxygenshadowcache.cpp
# next target
set(oxygenstyleconfig_LIB_SRCS
- oxygenanimationconfigitem.cpp
- oxygenbaseanimationconfigwidget.cpp
- oxygengenericanimationconfigitem.cpp
oxygenshadowconfigwidget.cpp
)
kde4_add_ui_files(oxygenstyleconfig_LIB_SRCS
- ui/oxygenanimationconfigitem.ui
- ui/oxygenanimationconfigwidget.ui
- ui/oxygengenericanimationconfigbox.ui
ui/oxygenshadowconfigurationui.ui
)
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenanimation.h
-// stores event filters and maps widgets to animations for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimation.h"
-#include "oxygenanimation.moc"
+++ /dev/null
-#ifndef oxygenanimation_h
-#define oxygenanimation_h
-//////////////////////////////////////////////////////////////////////////////
-// oxygenanimation.h
-// stores event filters and maps widgets to animations for animations
-// -------------------
-//
-// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include <QtCore/QWeakPointer>
-#include <QtCore/QPropertyAnimation>
-#include <QtCore/QVariant>
-
-#include "oxygen_export.h"
-
-namespace Oxygen
-{
-
- class OXYGEN_EXPORT Animation: public QPropertyAnimation
- {
-
- Q_OBJECT
-
- public:
-
- //! TimeLine shared pointer
- typedef QWeakPointer<Animation> Pointer;
-
- //! constructor
- Animation( int duration, QObject* parent ):
- QPropertyAnimation( parent )
- { setDuration( duration ); }
-
- //! destructor
- virtual ~Animation( void )
- {}
-
- //! true if running
- bool isRunning( void ) const
- { return state() == Animation::Running; }
-
- //! restart
- void restart( void )
- {
- if( isRunning() ) stop();
- start();
- }
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenanimationconfigitem.cpp
-// animation configuration item
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenanimationconfigitem.h"
-#include "oxygenanimationconfigitem.moc"
-#include "ui_oxygenanimationconfigitem.h"
-
-#include <QtCore/QTextStream>
-#include <KGlobal>
-#include <KIcon>
-#include <KLocale>
-#include <KMessageBox>
-
-namespace Oxygen
-{
-
- //_______________________________________________
- AnimationConfigItem::AnimationConfigItem( QWidget* parent, const QString& title, const QString& description ):
- QWidget( parent ),
- ui( new Ui_AnimationConfigItem() )
- {
-
- KGlobal::locale()->insertCatalog("liboxygenstyleconfig");
- ui->setupUi( this );
- layout()->setMargin(0);
-
- ui->configurationButton->setIcon( KIcon("configure") );
- ui->descriptionButton->setIcon(KIcon("dialog-information"));
-
- connect( ui->enableCheckBox, SIGNAL(toggled(bool)), SIGNAL(changed()) );
- connect( ui->descriptionButton, SIGNAL(clicked()), SLOT(about()) );
-
- setTitle( title );
- setDescription( description );
-
- }
-
- //________________________________________________________________
- AnimationConfigItem::~AnimationConfigItem( void )
- { delete ui; }
-
- //________________________________________________________________
- void AnimationConfigItem::setTitle( const QString& value )
- { ui->enableCheckBox->setText( value ); }
-
- //________________________________________________________________
- QString AnimationConfigItem::title( void ) const
- { return ui->enableCheckBox->text(); }
-
- //________________________________________________________________
- void AnimationConfigItem::setDescription( const QString& value )
- {
- _description = value;
- ui->descriptionButton->setEnabled( !_description.isEmpty() );
- }
-
- //________________________________________________________________
- void AnimationConfigItem::setEnabled( const bool& value )
- { ui->enableCheckBox->setChecked( value ); }
-
- //________________________________________________________________
- bool AnimationConfigItem::enabled( void ) const
- { return ui->enableCheckBox->isChecked(); }
-
- //________________________________________________________________
- QAbstractButton* AnimationConfigItem::configurationButton( void ) const
- { return ui->configurationButton; }
-
- //_______________________________________________
- void AnimationConfigItem::setConfigurationWidget( QWidget* widget )
- {
- widget->setEnabled( ui->enableCheckBox->isChecked() );
- connect( ui->enableCheckBox, SIGNAL(toggled(bool)), widget, SLOT(setEnabled(bool)) );
- connect( ui->configurationButton, SIGNAL(toggled(bool)), widget, SLOT(setVisible(bool)) );
- }
-
- //_______________________________________________
- void AnimationConfigItem::about( void )
- {
- if( description().isEmpty() ) return;
- KMessageBox::information( this, description(), i18n( "oxygen-settings - information" ) );
- return;
- }
-
-}
+++ /dev/null
-#ifndef oxygenanimationconfigitem_h
-#define oxygenanimationconfigitem_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenanimationconfigitem.h
-// animation configuration item
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygen_export.h"
-
-#include <QtGui/QAbstractButton>
-#include <QtGui/QWidget>
-#include <cassert>
-
-class Ui_AnimationConfigItem;
-
-namespace Oxygen
-{
-
- class OXYGEN_EXPORT AnimationConfigItem: public QWidget
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit AnimationConfigItem( QWidget* parent, const QString& title = QString(), const QString& description = QString() );
-
- //! destructor
- virtual ~AnimationConfigItem( void );
-
- //! title
- virtual void setTitle( const QString& );
-
- //! title
- virtual QString title( void ) const;
-
- //! description
- virtual void setDescription( const QString& );
-
- //! description
- virtual const QString& description( void ) const
- { return _description; }
-
- //! enability
- virtual void setEnabled( const bool& );
-
- //! enability
- virtual bool enabled( void ) const;
-
- //! config widget
- virtual QWidget* configurationWidget( void ) const = 0;
-
- //! initialize config widget
- virtual void initializeConfigurationWidget( QWidget* ) = 0;
-
- //! configuration button
- QAbstractButton* configurationButton( void ) const;
-
- signals:
-
- //! emmited when changed
- void changed( void );
-
- protected slots:
-
- //! about info
- virtual void about( void );
-
- protected:
-
- //! set configuration widget
- virtual void setConfigurationWidget( QWidget* widget );
-
- private:
-
- //! description
- QString _description;
-
- //! ui
- Ui_AnimationConfigItem* ui;
-
- };
-
-}
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygenanimationconfigwidget.cpp
-// animation configuration widget
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygenbaseanimationconfigwidget.h"
-#include "oxygenbaseanimationconfigwidget.moc"
-#include "oxygenanimationconfigitem.h"
-
-#include "ui_oxygenanimationconfigwidget.h"
-
-#include <QtGui/QButtonGroup>
-#include <QtGui/QHoverEvent>
-#include <QtCore/QTextStream>
-#include <KLocale>
-
-namespace Oxygen
-{
-
- //_______________________________________________
- BaseAnimationConfigWidget::BaseAnimationConfigWidget( QWidget* parent ):
- QWidget( parent ),
- ui( new Ui_AnimationConfigWidget() ),
- _row(0),
- _changed( false )
- {
-
- ui->setupUi( this );
- QGridLayout* layout( qobject_cast<QGridLayout*>( BaseAnimationConfigWidget::layout() ) );
- _row = layout->rowCount();
-
- }
-
- //_______________________________________________
- BaseAnimationConfigWidget::~BaseAnimationConfigWidget( void )
- { delete ui; }
-
- //_______________________________________________
- void BaseAnimationConfigWidget::updateItems( bool state )
- {
- if( !state ) return;
- foreach( AnimationConfigItem* item, findChildren<AnimationConfigItem*>() )
- { if( item->configurationWidget()->isVisible() ) item->configurationButton()->setChecked( false ); }
- }
-
- //_______________________________________________
- QCheckBox* BaseAnimationConfigWidget::animationsEnabled( void ) const
- { return ui->animationsEnabled; }
-
- //_______________________________________________
- void BaseAnimationConfigWidget::setupItem( QGridLayout* layout, AnimationConfigItem* item )
- {
- layout->addWidget( item, _row, 0, 1, 2 );
- ++_row;
-
- connect( item->configurationButton(), SIGNAL(toggled(bool)), SLOT(updateItems(bool)) );
-
- item->initializeConfigurationWidget( this );
- layout->addWidget( item->configurationWidget(), _row, 1, 1, 1 );
- ++_row;
-
- item->configurationWidget()->setVisible( false );
- connect( item->configurationButton(), SIGNAL(toggled(bool)), SIGNAL(layoutChanged()) );
- connect( item, SIGNAL(changed()), SLOT(updateChanged()) );
- }
-
-}
+++ /dev/null
-#ifndef oxygenbaseanimationconfigwidget_h
-#define oxygenbaseanimationconfigwidget_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygenbaseanimationconfigwidget.h
-// animation configuration item
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygen_export.h"
-
-#include <QtGui/QWidget>
-#include <QtGui/QLayout>
-#include <QtGui/QCheckBox>
-
-class Ui_AnimationConfigWidget;
-
-namespace Oxygen
-{
- class AnimationConfigItem;
-
- class OXYGEN_EXPORT BaseAnimationConfigWidget: public QWidget
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit BaseAnimationConfigWidget( QWidget* = 0 );
-
- //! destructor
- virtual ~BaseAnimationConfigWidget( void );
-
- //! true if changed
- virtual bool isChanged( void ) const
- { return _changed; }
-
- signals:
-
- //! emmited when layout is changed
- void layoutChanged( void );
-
- //! emmited when changed
- void changed( bool );
-
- public slots:
-
- //! read current configuration
- virtual void load( void ) = 0;
-
- //! save current configuration
- virtual void save( void ) = 0;
-
- protected slots:
-
- //! update visible ites
- virtual void updateItems( bool );
-
- //! check whether configuration is changed and emit appropriate signal if yes
- virtual void updateChanged() = 0;
-
- protected:
-
- //! get global animations enabled checkbox
- QCheckBox* animationsEnabled( void ) const;
-
- //! add item to ui
- virtual void setupItem( QGridLayout*, AnimationConfigItem* );
-
- //! set changed state
- virtual void setChanged( bool value )
- {
- _changed = value;
- emit changed( value );
- }
-
- //! user interface
- Ui_AnimationConfigWidget* ui;
-
- //! row index
- int _row;
-
- private:
-
- //! changed state
- bool _changed;
-
- };
-
-}
-
-
-#endif
+++ /dev/null
-//////////////////////////////////////////////////////////////////////////////
-// oxygengenericanimationconfigitem.cpp
-// animation configuration item
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygengenericanimationconfigitem.h"
-#include "oxygengenericanimationconfigitem.moc"
-
-#include "ui_oxygengenericanimationconfigbox.h"
-
-#include <KGlobal>
-
-namespace Oxygen
-{
-
- //_______________________________________________
- GenericAnimationConfigBox::GenericAnimationConfigBox(QWidget* parent):
- QFrame( parent ),
- ui( new Ui_GenericAnimationConfigBox() )
- {
- KGlobal::locale()->insertCatalog("liboxygenstyleconfig");
- ui->setupUi( this );
- }
-
- //_______________________________________________
- GenericAnimationConfigBox::~GenericAnimationConfigBox( void )
- { delete ui; }
-
- //_______________________________________________
- QSpinBox* GenericAnimationConfigBox::durationSpinBox( void ) const
- { return ui->durationSpinBox; }
-
- //_______________________________________________
- void GenericAnimationConfigItem::initializeConfigurationWidget( QWidget* parent )
- {
- assert( !_configurationWidget );
- _configurationWidget = new GenericAnimationConfigBox( parent );
- setConfigurationWidget( _configurationWidget.data() );
-
- connect( _configurationWidget.data()->durationSpinBox(), SIGNAL(valueChanged(int)), SIGNAL(changed()) );
-
- }
-
-}
+++ /dev/null
-#ifndef oxygengenericanimationconfigitem_h
-#define oxygengenericanimationconfigitem_h
-
-//////////////////////////////////////////////////////////////////////////////
-// oxygengenericanimationconfigitem.h
-// animation configuration item
-// -------------------
-//
-// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//////////////////////////////////////////////////////////////////////////////
-
-#include "oxygen_export.h"
-#include "oxygenanimationconfigitem.h"
-
-#include <QtCore/QWeakPointer>
-#include <QtGui/QFrame>
-#include <QtGui/QSpinBox>
-
-class Ui_GenericAnimationConfigBox;
-
-namespace Oxygen
-{
-
- class OXYGEN_EXPORT GenericAnimationConfigBox: public QFrame
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit GenericAnimationConfigBox(QWidget*);
-
- //! destructor
- virtual ~GenericAnimationConfigBox( void );
-
- //! duration spin box
- QSpinBox* durationSpinBox( void ) const;
-
- private:
-
- Ui_GenericAnimationConfigBox* ui;
-
- };
-
- //! generic animation config item
- class OXYGEN_EXPORT GenericAnimationConfigItem: public AnimationConfigItem
- {
-
- Q_OBJECT
-
- public:
-
- //! constructor
- explicit GenericAnimationConfigItem( QWidget* parent, const QString& title = QString(), const QString& description = QString() ):
- AnimationConfigItem( parent, title, description )
- {}
-
- //! configure
- virtual void initializeConfigurationWidget( QWidget* );
-
- //! configuration widget
- virtual QWidget* configurationWidget( void ) const
- {
- assert( _configurationWidget );
- return _configurationWidget.data();
- }
-
- //! duration
- virtual int duration( void ) const
- { return (_configurationWidget) ? _configurationWidget.data()->durationSpinBox()->value():0; }
-
- public slots:
-
- //! duration
- virtual void setDuration( int value )
- {
- if( _configurationWidget )
- { _configurationWidget.data()->durationSpinBox()->setValue( value ); }
- }
-
- private:
-
- //! configuration widget
- QWeakPointer<GenericAnimationConfigBox> _configurationWidget;
-
- };
-
-}
-
-#endif
{
setEnabled( true );
- setMaxIndex( 256 );
}
}
//_______________________________________________________
- void ShadowCache::setAnimationsDuration( int value )
- {
- setMaxIndex( qMin( 256, int( (120*value)/1000 ) ) );
- invalidateCaches();
- }
-
- //_______________________________________________________
bool ShadowCache::isEnabled( QPalette::ColorGroup group ) const
{
if( group == QPalette::Active ) return ActiveShadowConfiguration::enabled();
}
//_______________________________________________________
- TileSet* ShadowCache::tileSet( Key key, qreal opacity )
- {
-
- int index( opacity*_maxIndex );
- assert( index <= _maxIndex );
-
- // construct key
- key.index = index;
-
- // check if tileSet already in cache
- int hash( key.hash() );
- if( _enabled && _animatedShadowCache.contains(hash) ) return _animatedShadowCache.object(hash);
-
- // create shadow and tileset otherwise
- qreal size( shadowSize() + overlap );
-
- QPixmap shadow( size*2, size*2 );
- shadow.fill( Qt::transparent );
- QPainter p( &shadow );
- p.setRenderHint( QPainter::Antialiasing );
-
- QPixmap inactiveShadow( pixmap( key, false ) );
- if( !inactiveShadow.isNull() )
- {
- QPainter pp( &inactiveShadow );
- pp.setRenderHint( QPainter::Antialiasing );
- pp.setCompositionMode(QPainter::CompositionMode_DestinationIn);
- pp.fillRect( inactiveShadow.rect(), QColor( 0, 0, 0, 255*(1.0-opacity ) ) );
- }
-
- QPixmap activeShadow( pixmap( key, true ) );
- if( !activeShadow.isNull() )
- {
- QPainter pp( &activeShadow );
- pp.setRenderHint( QPainter::Antialiasing );
- pp.setCompositionMode(QPainter::CompositionMode_DestinationIn);
- pp.fillRect( activeShadow.rect(), QColor( 0, 0, 0, 255*( opacity ) ) );
- }
-
- p.drawPixmap( QPointF(0,0), inactiveShadow );
- p.drawPixmap( QPointF(0,0), activeShadow );
- p.end();
-
- TileSet* tileSet = new TileSet(shadow, size, size, 1, 1);
- _animatedShadowCache.insert( hash, tileSet );
- return tileSet;
-
- }
-
- //_______________________________________________________
QPixmap ShadowCache::pixmap( const Key& key, bool active ) const
{
//! read configuration
void readConfig( void );
- //! animations duration
- void setAnimationsDuration( int );
-
//! cache size
void setEnabled( bool enabled )
{
{
_shadowCache.setMaxCost( 1<<6 );
- _animatedShadowCache.setMaxCost( _maxIndex<<6 );
} else {
_shadowCache.setMaxCost( 1 );
- _animatedShadowCache.setMaxCost( 1 );
-
- }
- }
-
- //! max animation index
- int maxIndex( void ) const
- { return _maxIndex; }
-
- //! max animation index
- void setMaxIndex( int value )
- {
- _maxIndex = value;
- if( _enabled )
- {
-
- _shadowCache.setMaxCost( 1<<6 );
- _animatedShadowCache.setMaxCost( _maxIndex<<6 );
}
-
}
//! invalidate caches
void invalidateCaches( void )
{
_shadowCache.clear();
- _animatedShadowCache.clear();
}
//! true if shadow is enabled for a given group
//! get shadow matching client
TileSet* tileSet( const Key& );
- //! get shadow matching client and opacity
- TileSet* tileSet( Key, qreal );
-
//! simple pixmap
QPixmap pixmap( const Key& key ) const
{ return pixmap( key, key.active ); }
//! caching enable state
bool _enabled;
- //! max index
- /*! it is used to set caches max cost, and calculate animation opacity */
- int _maxIndex;
-
//! cache
typedef QCache<int, TileSet> TileSetCache;
//! shadow cache
TileSetCache _shadowCache;
- //! animated shadow cache
- TileSetCache _animatedShadowCache;
-
};
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>AnimationConfigItem</class>
- <widget class="QWidget" name="AnimationConfigItem">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>31</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QCheckBox" name="enableCheckBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>CheckBox</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="configurationButton">
- <property name="text">
- <string>...</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="autoRaise">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="descriptionButton">
- <property name="text">
- <string>...</string>
- </property>
- <property name="autoRaise">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>AnimationConfigWidget</class>
- <widget class="QWidget" name="AnimationConfigWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>300</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" colspan="2">
- <widget class="QCheckBox" name="animationsEnabled">
- <property name="text">
- <string>Enable animations</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>GenericAnimationConfigBox</class>
- <widget class="QFrame" name="GenericAnimationConfigBox">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>38</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="windowTitle">
- <string>Frame</string>
- </property>
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Sunken</enum>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Duration:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>durationSpinBox</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KIntSpinBox" name="durationSpinBox">
- <property name="suffix">
- <string>ms</string>
- </property>
- <property name="minimum">
- <number>5</number>
- </property>
- <property name="maximum">
- <number>2000</number>
- </property>
- <property name="singleStep">
- <number>5</number>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KIntSpinBox</class>
- <extends>QSpinBox</extends>
- <header>knuminput.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>