qskinny/src/controls/QskSkinStateChanger.h

49 lines
1.2 KiB
C
Raw Normal View History

2021-12-23 17:15:07 +00:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
2023-04-06 07:23:37 +00:00
* SPDX-License-Identifier: BSD-3-Clause
2021-12-23 17:15:07 +00:00
*****************************************************************************/
#ifndef QSK_SKIN_STATE_CHANGER_H
#define QSK_SKIN_STATE_CHANGER_H
#include "QskAspect.h"
#include "QskSkinnable.h"
class QskSkinStateChanger
{
public:
QskSkinStateChanger( const QskSkinnable* );
2021-12-23 17:15:07 +00:00
~QskSkinStateChanger();
void setStates( QskAspect::States, int sampleIndex = -1 );
2023-06-30 12:24:31 +00:00
void resetStates();
2021-12-27 16:33:06 +00:00
2021-12-23 17:15:07 +00:00
private:
QskSkinnable* m_skinnable;
2021-12-27 16:33:06 +00:00
const QskAspect::States m_oldStates;
2021-12-23 17:15:07 +00:00
};
inline QskSkinStateChanger::QskSkinStateChanger( const QskSkinnable* skinnable )
2021-12-23 17:15:07 +00:00
: m_skinnable( const_cast< QskSkinnable* >( skinnable ) )
, m_oldStates( skinnable->skinStates() )
{
}
inline QskSkinStateChanger::~QskSkinStateChanger()
{
2023-06-30 12:24:31 +00:00
resetStates();
2021-12-23 17:15:07 +00:00
}
inline void QskSkinStateChanger::setStates(
QskAspect::States states, int sampleIndex )
2021-12-27 16:33:06 +00:00
{
m_skinnable->replaceSkinStates( states, sampleIndex );
2021-12-27 16:33:06 +00:00
}
2023-06-30 12:24:31 +00:00
inline void QskSkinStateChanger::resetStates()
{
m_skinnable->replaceSkinStates( m_oldStates, -1 );
2023-06-30 12:24:31 +00:00
}
2021-12-23 17:15:07 +00:00
#endif