Files
lmms/include/LcdFloatSpinBox.h
Martin Pavelek 17ea61676f Add LcdFloatSpinBox (extracted from microtonal PR) (#5865)
* Add changes extracted from microtonal PR

* Apply suggestions from code review

Co-authored-by: IanCaio <iancaio_dev@hotmail.com>

* Apply suggestions from code review

(adding oneliner spaces)

Co-authored-by: IanCaio <iancaio_dev@hotmail.com>

* Update src/gui/widgets/LcdFloatSpinBox.cpp

Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>

* Apply suggestions from code review

Co-authored-by: Dominic Clark <mrdomclark@gmail.com>

* Implement suggestions from review

* Reorder constructor parameters, remove old code for cursor movement and hiding from Lcd*SpinBoxes

* Apply suggestions from code review

Co-authored-by: IanCaio <iancaio_dev@hotmail.com>

* Fix right margin width in seamless mode

* Add explanation to border drawing code

Co-authored-by: IanCaio <iancaio_dev@hotmail.com>
Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>
Co-authored-by: Dominic Clark <mrdomclark@gmail.com>
2021-03-15 14:06:48 -03:00

84 lines
2.3 KiB
C++

/*
* LcdFloatSpinBox.h - class LcdFloatSpinBox (LcdSpinBox for floats)
*
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2020 Martin Pavelek <he29.HS/at/gmail.com>
*
* This file is part of LMMS - https://lmms.io
*
* 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.
*
* This program 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef LCD_FLOATSPINBOX_H
#define LCD_FLOATSPINBOX_H
#include <QString>
#include "LcdWidget.h"
#include "AutomatableModelView.h"
class LMMS_EXPORT LcdFloatSpinBox : public QWidget, public FloatModelView
{
Q_OBJECT
public:
LcdFloatSpinBox(int numWhole, int numFrac, const QString& name = QString(), QWidget* parent = nullptr);
LcdFloatSpinBox(int numWhole, int numFrac, const QString& style, const QString& name, QWidget* parent = nullptr);
void modelChanged() override
{
ModelView::modelChanged();
update();
}
void setLabel(const QString &label) { m_label = label; }
public slots:
virtual void update();
protected:
void contextMenuEvent(QContextMenuEvent *me) override;
void mousePressEvent(QMouseEvent *me) override;
void mouseMoveEvent(QMouseEvent *me) override;
void mouseReleaseEvent(QMouseEvent *me) override;
void wheelEvent(QWheelEvent *we) override;
void mouseDoubleClickEvent(QMouseEvent *me) override;
void paintEvent(QPaintEvent *pe) override;
private:
void layoutSetup(const QString &style = QString("19green"));
void enterValue();
float getStep() const;
LcdWidget m_wholeDisplay;
LcdWidget m_fractionDisplay;
bool m_mouseMoving;
bool m_intStep;
QPoint m_origMousePos;
int m_displayOffset;
QString m_label;
signals:
void manualChange();
};
using LcdFloatSpinBoxModel = FloatModel;
#endif