Introduce SimpleTextFloat
Introduce the new class SimpleTextFloat which simply shows a text and that works like a pseudo tool tip with a narrow margin. It was extracted from TextFloat to adhere to the single responsibility principle. The new class is used by: * Fader: display the current volume when moving the fader * Knob: display the current value when the knob is moved * PianoRoll: display the current value when setting the note volume and panning Add stylings for the new widget in style.css.
This commit is contained in:
@@ -70,7 +70,7 @@ QToolTip {
|
||||
color: #4afd85;
|
||||
}
|
||||
|
||||
lmms--gui--TextFloat {
|
||||
lmms--gui--TextFloat, lmms--gui--SimpleTextFloat {
|
||||
border-radius: 4px;
|
||||
background: qlineargradient(spread:reflect, x1:0.5, y1:0.5, x2:0.5, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(50, 50, 50, 220));
|
||||
opacity: 175;
|
||||
|
||||
@@ -100,7 +100,7 @@ QToolTip {
|
||||
color: #d1d8e4;
|
||||
}
|
||||
|
||||
lmms--gui--TextFloat {
|
||||
lmms--gui--TextFloat, lmms--gui--SimpleTextFloat {
|
||||
background: #040506;
|
||||
color: #d1d8e4;
|
||||
}
|
||||
|
||||
@@ -55,10 +55,11 @@
|
||||
|
||||
#include "AutomatableModelView.h"
|
||||
|
||||
|
||||
namespace lmms::gui
|
||||
{
|
||||
|
||||
class TextFloat;
|
||||
class SimpleTextFloat;
|
||||
|
||||
|
||||
class LMMS_EXPORT Fader : public QWidget, public FloatModelView
|
||||
@@ -164,7 +165,7 @@ private:
|
||||
int m_moveStartPoint;
|
||||
float m_startValue;
|
||||
|
||||
static TextFloat * s_textFloat;
|
||||
static SimpleTextFloat * s_textFloat;
|
||||
|
||||
QColor m_peakGreen;
|
||||
QColor m_peakRed;
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace lmms::gui
|
||||
{
|
||||
|
||||
|
||||
class TextFloat;
|
||||
class SimpleTextFloat;
|
||||
|
||||
enum knobTypes
|
||||
{
|
||||
@@ -175,7 +175,7 @@ private:
|
||||
}
|
||||
|
||||
|
||||
static TextFloat * s_textFloat;
|
||||
static SimpleTextFloat * s_textFloat;
|
||||
|
||||
QString m_label;
|
||||
bool m_isHtmlLabel;
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace gui
|
||||
|
||||
class ComboBox;
|
||||
class PositionLine;
|
||||
class TextFloat;
|
||||
class SimpleTextFloat;
|
||||
class TimeLineWidget;
|
||||
|
||||
|
||||
@@ -345,7 +345,7 @@ private:
|
||||
|
||||
static std::array<PianoRollKeyTypes, 12> prKeyOrder;
|
||||
|
||||
static TextFloat * s_textFloat;
|
||||
static SimpleTextFloat * s_textFloat;
|
||||
|
||||
ComboBoxModel m_zoomingModel;
|
||||
ComboBoxModel m_zoomingYModel;
|
||||
|
||||
61
include/SimpleTextFloat.h
Normal file
61
include/SimpleTextFloat.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* TextFloat.h - class textFloat, a floating text-label
|
||||
*
|
||||
* Copyright (c) 2023 LMMS team
|
||||
*
|
||||
* 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 SIMPLE_TEXT_FLOAT_H
|
||||
#define SIMPLE_TEXT_FLOAT_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "lmms_export.h"
|
||||
|
||||
class QLabel;
|
||||
|
||||
namespace lmms::gui
|
||||
{
|
||||
|
||||
class LMMS_EXPORT SimpleTextFloat : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SimpleTextFloat();
|
||||
~SimpleTextFloat() override = default;
|
||||
|
||||
void setText( const QString & _text );
|
||||
|
||||
void setVisibilityTimeOut( int _msecs );
|
||||
|
||||
void moveGlobal( QWidget * _w, const QPoint & _offset )
|
||||
{
|
||||
move( _w->mapToGlobal( QPoint( 0, 0 ) ) + _offset );
|
||||
}
|
||||
|
||||
private:
|
||||
QLabel * m_textLabel;
|
||||
};
|
||||
|
||||
|
||||
} // namespace lmms::gui
|
||||
|
||||
#endif
|
||||
@@ -112,6 +112,7 @@ SET(LMMS_SRCS
|
||||
gui/widgets/NStateButton.cpp
|
||||
gui/widgets/Oscilloscope.cpp
|
||||
gui/widgets/PixmapButton.cpp
|
||||
gui/widgets/SimpleTextFloat.cpp
|
||||
gui/widgets/TabBar.cpp
|
||||
gui/widgets/TabWidget.cpp
|
||||
gui/widgets/TempoSyncKnob.cpp
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
#include "PatternStore.h"
|
||||
#include "PianoView.h"
|
||||
#include "PositionLine.h"
|
||||
#include "SimpleTextFloat.h"
|
||||
#include "SongEditor.h"
|
||||
#include "StepRecorderWidget.h"
|
||||
#include "TextFloat.h"
|
||||
@@ -127,7 +128,7 @@ QPixmap * PianoRoll::s_toolMove = nullptr;
|
||||
QPixmap * PianoRoll::s_toolOpen = nullptr;
|
||||
QPixmap* PianoRoll::s_toolKnife = nullptr;
|
||||
|
||||
TextFloat * PianoRoll::s_textFloat = nullptr;
|
||||
SimpleTextFloat * PianoRoll::s_textFloat = nullptr;
|
||||
|
||||
static std::array<QString, 12> s_noteStrings {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
|
||||
|
||||
@@ -290,7 +291,7 @@ PianoRoll::PianoRoll() :
|
||||
// init text-float
|
||||
if( s_textFloat == nullptr )
|
||||
{
|
||||
s_textFloat = new TextFloat;
|
||||
s_textFloat = new SimpleTextFloat;
|
||||
}
|
||||
|
||||
setAttribute( Qt::WA_OpaquePaintEvent, true );
|
||||
|
||||
@@ -54,13 +54,13 @@
|
||||
#include "embed.h"
|
||||
#include "CaptionMenu.h"
|
||||
#include "ConfigManager.h"
|
||||
#include "TextFloat.h"
|
||||
#include "SimpleTextFloat.h"
|
||||
|
||||
namespace lmms::gui
|
||||
{
|
||||
|
||||
|
||||
TextFloat * Fader::s_textFloat = nullptr;
|
||||
SimpleTextFloat * Fader::s_textFloat = nullptr;
|
||||
QPixmap * Fader::s_back = nullptr;
|
||||
QPixmap * Fader::s_leds = nullptr;
|
||||
QPixmap * Fader::s_knob = nullptr;
|
||||
@@ -83,7 +83,7 @@ Fader::Fader( FloatModel * _model, const QString & _name, QWidget * _parent ) :
|
||||
{
|
||||
if( s_textFloat == nullptr )
|
||||
{
|
||||
s_textFloat = new TextFloat;
|
||||
s_textFloat = new SimpleTextFloat;
|
||||
}
|
||||
if( ! s_back )
|
||||
{
|
||||
@@ -125,7 +125,7 @@ Fader::Fader( FloatModel * model, const QString & name, QWidget * parent, QPixma
|
||||
{
|
||||
if( s_textFloat == nullptr )
|
||||
{
|
||||
s_textFloat = new TextFloat;
|
||||
s_textFloat = new SimpleTextFloat;
|
||||
}
|
||||
|
||||
m_back = back;
|
||||
|
||||
@@ -45,14 +45,14 @@
|
||||
#include "LocaleHelper.h"
|
||||
#include "MainWindow.h"
|
||||
#include "ProjectJournal.h"
|
||||
#include "SimpleTextFloat.h"
|
||||
#include "StringPairDrag.h"
|
||||
#include "TextFloat.h"
|
||||
|
||||
|
||||
namespace lmms::gui
|
||||
{
|
||||
|
||||
TextFloat * Knob::s_textFloat = nullptr;
|
||||
SimpleTextFloat * Knob::s_textFloat = nullptr;
|
||||
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ void Knob::initUi( const QString & _name )
|
||||
{
|
||||
if( s_textFloat == nullptr )
|
||||
{
|
||||
s_textFloat = new TextFloat;
|
||||
s_textFloat = new SimpleTextFloat;
|
||||
}
|
||||
|
||||
setWindowTitle( _name );
|
||||
|
||||
62
src/gui/widgets/SimpleTextFloat.cpp
Normal file
62
src/gui/widgets/SimpleTextFloat.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* TextFloat.cpp - class textFloat, a floating text-label
|
||||
*
|
||||
* Copyright (c) LMMS team
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "SimpleTextFloat.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QStyleOption>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
#include "GuiApplication.h"
|
||||
#include "MainWindow.h"
|
||||
|
||||
namespace lmms::gui
|
||||
{
|
||||
|
||||
|
||||
SimpleTextFloat::SimpleTextFloat() :
|
||||
QWidget(getGUI()->mainWindow(), Qt::ToolTip)
|
||||
{
|
||||
QHBoxLayout * layout = new QHBoxLayout(this);
|
||||
layout->setMargin(3);
|
||||
setLayout(layout);
|
||||
|
||||
m_textLabel = new QLabel(this);
|
||||
layout->addWidget(m_textLabel);
|
||||
}
|
||||
|
||||
void SimpleTextFloat::setText( const QString & _text )
|
||||
{
|
||||
m_textLabel->setText(_text);
|
||||
}
|
||||
|
||||
|
||||
void SimpleTextFloat::setVisibilityTimeOut( int _msecs )
|
||||
{
|
||||
QTimer::singleShot( _msecs, this, SLOT(hide()));
|
||||
show();
|
||||
}
|
||||
|
||||
} // namespace lmms::gui
|
||||
Reference in New Issue
Block a user