first re-commit.
This commit is contained in:
98
swflipdigit.h
Normal file
98
swflipdigit.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* contains copy-written material from qt example code:
|
||||
* @see shaped clock example
|
||||
* @see embedded/flipdigits example
|
||||
*
|
||||
* **/
|
||||
|
||||
|
||||
#ifndef SWFLIPDIGIT_H
|
||||
#define SWFLIPDIGIT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimeLine>
|
||||
|
||||
#include <swdialwidget.h>
|
||||
#include <swrangevalue.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Simuliert die 'Klappzahl'-Darstellung einer Ziffer.
|
||||
*/
|
||||
|
||||
class SWFlipDigit : public QWidget, public SWDialWidget, public SWRangeValue
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
enum FlipMode
|
||||
{
|
||||
Slide,
|
||||
Flip,
|
||||
Rotate
|
||||
};
|
||||
|
||||
explicit SWFlipDigit(QWidget *parent = nullptr);
|
||||
virtual ~SWFlipDigit();
|
||||
|
||||
void setTransition( FlipMode tr );
|
||||
FlipMode transition() const;
|
||||
|
||||
void onDialDeltaChanged( int delta ) override;
|
||||
|
||||
public slots:
|
||||
|
||||
virtual void setValue( int n ) override;
|
||||
void flipTo( int n );
|
||||
|
||||
protected:
|
||||
|
||||
const char* SWDEFAULTFONT = "Grado Gradoo Nf";
|
||||
const double SWSCALEFACTOR = 2.7;
|
||||
const double SWFONTSCALE = 0.85;
|
||||
|
||||
void drawFrame( QPainter* p, const QRect& rect );
|
||||
QPixmap drawDigits(int n, const QRect &rect);
|
||||
void preparePixmap();
|
||||
|
||||
void resizeEvent( QResizeEvent* event ) override;
|
||||
virtual void paintEvent( QPaintEvent* event ) override;
|
||||
|
||||
void paintStatic();
|
||||
void paintSlide();
|
||||
void paintFlip();
|
||||
void paintRotate();
|
||||
|
||||
//const int SWPADWIDTH = 0;//1;//15;
|
||||
|
||||
double _scaleFactor = SWSCALEFACTOR;
|
||||
double _fontScale = SWFONTSCALE;
|
||||
|
||||
QString _fontFamily;
|
||||
FlipMode _transition;
|
||||
QPixmap _pixmap;
|
||||
QPixmap _lastPixmap;
|
||||
QTimeLine _animator;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // SWFLIPDIGIT_H
|
Reference in New Issue
Block a user