formal adjustments

This commit is contained in:
Uwe Rathmann 2023-02-17 14:05:05 +01:00
parent eb5f3d3bcf
commit 8df1551701
4 changed files with 86 additions and 61 deletions

View File

@ -1,21 +1,24 @@
/****************************************************************************** /******************************************************************************
* Copyright (C) 2023 Edelhirsch Software GmbH * QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License * This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/ *****************************************************************************/
#include "QskSpinBox.h" #include "QskSpinBox.h"
#include <QskLinearBox.h> #include "QskLinearBox.h"
#include <QskGridBox.h> #include "QskGridBox.h"
#include <QskTextInput.h> #include "QskTextInput.h"
#include <QskBoxShapeMetrics.h> #include "QskBoxShapeMetrics.h"
#include <QskBoxBorderColors.h> #include "QskBoxBorderColors.h"
#include <QskBoxBorderMetrics.h> #include "QskBoxBorderMetrics.h"
#include <QskSkinlet.h> #include "QskSkinlet.h"
#include <QskEvent.h> #include "QskIntervalF.h"
#include "QskEvent.h"
#include <QtMath> #include <QtMath>
#include <QGuiApplication> #include <QGuiApplication>
#include <QStyleHints> #include <QStyleHints>
#include <QskIntervalF.h>
#include <array>
QSK_SUBCONTROL(QskSpinBox, Inc) QSK_SUBCONTROL(QskSpinBox, Inc)
QSK_SUBCONTROL(QskSpinBox, Dec) QSK_SUBCONTROL(QskSpinBox, Dec)

View File

@ -1,48 +1,49 @@
/****************************************************************************** /******************************************************************************
* Copyright (C) 2023 Edelhirsch Software GmbH * QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License * This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/ *****************************************************************************/
#pragma once #ifndef QSK_SPIN_BOX_H
#define QSK_SPIN_BOX_H
#include <QskControl.h>
#include <QskPushButton.h>
#include <QskBoundedInput.h> #include <QskBoundedInput.h>
class QSK_EXPORT QskSpinBox : public QskBoundedInput class QSK_EXPORT QskSpinBox : public QskBoundedInput
{ {
Q_OBJECT Q_OBJECT
using Inherited = QskBoundedInput; Q_PROPERTY(qreal value READ value NOTIFY valueChanged)
using Inherited = QskBoundedInput;
public: public:
Q_PROPERTY(qreal value READ value NOTIFY valueChanged) QSK_SUBCONTROLS(Inc, Dec, IncText, DecText, TextPanel, Text, Layout)
QSK_SUBCONTROLS(Inc, Dec, IncText, DecText, TextPanel, Text, Layout) QSK_STATES( Pressed )
QSK_STATES( Pressed )
explicit QskSpinBox( QQuickItem* parent = nullptr ); explicit QskSpinBox( QQuickItem* parent = nullptr );
~QskSpinBox() override; ~QskSpinBox() override;
void increment( qreal offset ) override; void increment( qreal offset ) override;
qreal value() const; qreal value() const;
Q_SIGNALS: Q_SIGNALS:
void valueChanged(qreal value); void valueChanged( qreal );
void focusIndexChanged( int );
private: private:
Q_SIGNAL void focusIndexChanged(int index); void hoverEnterEvent( QHoverEvent* ) override;
void hoverLeaveEvent( QHoverEvent* ) override;
void hoverMoveEvent( QHoverEvent* ) override;
void hoverEnterEvent( QHoverEvent* event) override; void mouseReleaseEvent( QMouseEvent* ) override;
void hoverLeaveEvent( QHoverEvent* event) override; void mousePressEvent( QMouseEvent* ) override;
void hoverMoveEvent( QHoverEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override; void keyPressEvent( QKeyEvent* ) override;
void mousePressEvent(QMouseEvent* event) override; void keyReleaseEvent( QKeyEvent* ) override;
void keyPressEvent( QKeyEvent* event ) override; void focusInEvent( QFocusEvent* ) override;
void keyReleaseEvent( QKeyEvent* event ) override; QRectF focusIndicatorRect() const override;
void focusInEvent(QFocusEvent* event) override; class PrivateData;
QRectF focusIndicatorRect() const override; std::unique_ptr<PrivateData> m_data;
class PrivateData;
std::unique_ptr<PrivateData> m_data;
}; };
#endif

View File

@ -1,11 +1,12 @@
/****************************************************************************** /******************************************************************************
* Copyright (C) 2023 Edelhirsch Software GmbH * QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License * This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/ *****************************************************************************/
#include "QskSpinBoxSkinlet.h" #include "QskSpinBoxSkinlet.h"
#include "QskSpinBox.h" #include "QskSpinBox.h"
#include <QFontMetrics>
#include <qfontmetrics.h>
const auto INC_TEXT = QStringLiteral("+"); const auto INC_TEXT = QStringLiteral("+");
const auto DEC_TEXT = QStringLiteral("-"); const auto DEC_TEXT = QStringLiteral("-");

View File

@ -1,28 +1,48 @@
/****************************************************************************** /******************************************************************************
* Copyright (C) 2023 Edelhirsch Software GmbH * QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License * This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/ *****************************************************************************/
#pragma once #ifndef QSK_SPIN_BOX_SKINLET_H
#define QSK_SPIN_BOX_SKINLET_H
#include <QskSkinlet.h> #include <QskSkinlet.h>
class QSK_EXPORT QskSpinBoxSkinlet : public QskSkinlet class QSK_EXPORT QskSpinBoxSkinlet : public QskSkinlet
{ {
Q_GADGET Q_GADGET
using Inherited = QskSkinlet; using Inherited = QskSkinlet;
public:
enum NodeRole public:
{ enum NodeRole
IncPanel, IncText, DecPanel, DecText, TextPanel, TextText, RoleCount {
}; IncPanel,
Q_INVOKABLE QskSpinBoxSkinlet( QskSkin* = nullptr ); IncText,
protected: DecPanel,
int sampleCount( const QskSkinnable*, QskAspect::Subcontrol ) const override; DecText,
QRectF sampleRect( const QskSkinnable*, const QRectF&, QskAspect::Subcontrol, int index ) const override; TextPanel,
QskAspect::States sampleStates(const QskSkinnable* skinnable, QskAspect::Subcontrol subControl, int index ) const override; TextText,
QSizeF sizeHint( const QskSkinnable*, Qt::SizeHint, const QSizeF& ) const override; RoleCount
QRectF subControlRect( const QskSkinnable*, const QRectF&, QskAspect::Subcontrol ) const override; };
QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override;
QSGNode* updateSampleNode( const QskSkinnable* skinnable, QskAspect::Subcontrol subControl, int index, QSGNode* node ) const override; Q_INVOKABLE QskSpinBoxSkinlet( QskSkin* = nullptr );
protected:
int sampleCount( const QskSkinnable*, QskAspect::Subcontrol ) const override;
QRectF sampleRect( const QskSkinnable*, const QRectF&,
QskAspect::Subcontrol, int index ) const override;
QskAspect::States sampleStates( const QskSkinnable*,
QskAspect::Subcontrol, int index ) const override;
QSizeF sizeHint( const QskSkinnable*, Qt::SizeHint, const QSizeF& ) const override;
QRectF subControlRect( const QskSkinnable*,
const QRectF&, QskAspect::Subcontrol ) const override;
QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override;
QSGNode* updateSampleNode( const QskSkinnable*,
QskAspect::Subcontrol, int index, QSGNode* node ) const override;
}; };
#endif