diff --git a/data/themes/classic/style.css b/data/themes/classic/style.css index 58ec5dc09..2880fe661 100644 --- a/data/themes/classic/style.css +++ b/data/themes/classic/style.css @@ -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; diff --git a/data/themes/default/style.css b/data/themes/default/style.css index f4c651c9e..a9646cfe4 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -100,7 +100,7 @@ QToolTip { color: #d1d8e4; } -lmms--gui--TextFloat { +lmms--gui--TextFloat, lmms--gui--SimpleTextFloat { background: #040506; color: #d1d8e4; } diff --git a/include/Fader.h b/include/Fader.h index 54acfc57d..d0ee302cb 100644 --- a/include/Fader.h +++ b/include/Fader.h @@ -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; diff --git a/include/Knob.h b/include/Knob.h index 16ac7ed01..8976dc9ca 100644 --- a/include/Knob.h +++ b/include/Knob.h @@ -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; diff --git a/include/PianoRoll.h b/include/PianoRoll.h index c1973f407..5469e70f9 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -60,7 +60,7 @@ namespace gui class ComboBox; class PositionLine; -class TextFloat; +class SimpleTextFloat; class TimeLineWidget; @@ -345,7 +345,7 @@ private: static std::array prKeyOrder; - static TextFloat * s_textFloat; + static SimpleTextFloat * s_textFloat; ComboBoxModel m_zoomingModel; ComboBoxModel m_zoomingYModel; diff --git a/include/SimpleTextFloat.h b/include/SimpleTextFloat.h new file mode 100644 index 000000000..1d029c189 --- /dev/null +++ b/include/SimpleTextFloat.h @@ -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 + +#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 diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 1000ba51d..9f940c035 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -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 diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 5f294d6e8..0cf72e5cb 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.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 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 ); diff --git a/src/gui/widgets/Fader.cpp b/src/gui/widgets/Fader.cpp index e2d6d8218..4cc5802a4 100644 --- a/src/gui/widgets/Fader.cpp +++ b/src/gui/widgets/Fader.cpp @@ -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; diff --git a/src/gui/widgets/Knob.cpp b/src/gui/widgets/Knob.cpp index 049a86be1..8640bb81d 100644 --- a/src/gui/widgets/Knob.cpp +++ b/src/gui/widgets/Knob.cpp @@ -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 ); diff --git a/src/gui/widgets/SimpleTextFloat.cpp b/src/gui/widgets/SimpleTextFloat.cpp new file mode 100644 index 000000000..e6625063b --- /dev/null +++ b/src/gui/widgets/SimpleTextFloat.cpp @@ -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 +#include +#include +#include + +#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