File indexing completed on 2024-05-19 05:35:21

0001 //////////////////////////////////////////////////////////////////////////////
0002 // oxygenspinboxdata.cpp
0003 // spinbox data container for up/down arrow hover (mouse-over) animations
0004 // -------------------
0005 //
0006 // SPDX-FileCopyrightText: 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
0007 //
0008 // SPDX-License-Identifier: MIT
0009 //////////////////////////////////////////////////////////////////////////////
0010 
0011 #include "oxygenspinboxdata.h"
0012 
0013 namespace Oxygen
0014 {
0015 //________________________________________________
0016 SpinBoxData::SpinBoxData(QObject *parent, QWidget *target, int duration)
0017     : AnimationData(parent, target)
0018 {
0019     _upArrowData._animation = new Animation(duration, this);
0020     _downArrowData._animation = new Animation(duration, this);
0021     setupAnimation(upArrowAnimation(), "upArrowOpacity");
0022     setupAnimation(downArrowAnimation(), "downArrowOpacity");
0023 }
0024 
0025 //______________________________________________
0026 bool SpinBoxData::Data::updateState(bool value)
0027 {
0028     if (_state == value)
0029         return false;
0030     else {
0031         _state = value;
0032         _animation.data()->setDirection(_state ? Animation::Forward : Animation::Backward);
0033         if (!_animation.data()->isRunning())
0034             _animation.data()->start();
0035         return true;
0036     }
0037 }
0038 }