Merge pull request #6607 from michaelgregorius/ImproveReadabilityOfTextFloat

Improve readability of text floats
This commit is contained in:
Michael Gregorius
2023-04-29 16:53:58 +02:00
committed by GitHub
13 changed files with 233 additions and 182 deletions

View File

@@ -54,10 +54,11 @@
#include "AutomatableModelView.h"
namespace lmms::gui
{
class TextFloat;
class SimpleTextFloat;
class LMMS_EXPORT Fader : public QWidget, public FloatModelView
@@ -163,7 +164,7 @@ private:
int m_moveStartPoint;
float m_startValue;
static TextFloat * s_textFloat;
static SimpleTextFloat * s_textFloat;
QColor m_peakGreen;
QColor m_peakRed;

View File

@@ -40,7 +40,7 @@ namespace lmms::gui
{
class TextFloat;
class SimpleTextFloat;
enum knobTypes
{
@@ -174,7 +174,7 @@ private:
}
static TextFloat * s_textFloat;
static SimpleTextFloat * s_textFloat;
QString m_label;
bool m_isHtmlLabel;

View File

@@ -60,7 +60,7 @@ namespace gui
class ComboBox;
class PositionLine;
class TextFloat;
class SimpleTextFloat;
class TimeLineWidget;
@@ -347,7 +347,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
View 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

View File

@@ -26,10 +26,11 @@
#define LMMS_GUI_TEXT_FLOAT_H
#include <QWidget>
#include <QPixmap>
#include "lmms_export.h"
class QLabel;
namespace lmms::gui
{
@@ -40,41 +41,34 @@ public:
TextFloat();
~TextFloat() override = default;
void setTitle( const QString & _title );
void setText( const QString & _text );
void setPixmap( const QPixmap & _pixmap );
void setTitle(const QString & title);
void setText(const QString & text);
void setPixmap(const QPixmap & pixmap);
void setVisibilityTimeOut( int _msecs );
void setVisibilityTimeOut(int msecs);
static TextFloat * displayMessage(const QString & title,
const QString & msg,
const QPixmap & pixmap = QPixmap(),
int timeout = 2000,
QWidget * parent = nullptr);
static TextFloat * displayMessage( const QString & _msg,
int _timeout = 2000,
QWidget * _parent = nullptr,
int _add_y_margin = 0 );
static TextFloat * displayMessage( const QString & _title,
const QString & _msg,
const QPixmap & _pixmap =
QPixmap(),
int _timeout = 2000,
QWidget * _parent = nullptr );
void moveGlobal( QWidget * _w, const QPoint & _offset )
void moveGlobal(QWidget * w, const QPoint & offset)
{
move( _w->mapToGlobal( QPoint( 0, 0 ) )+_offset );
move(w->mapToGlobal(QPoint(0, 0)) + offset);
}
protected:
void paintEvent( QPaintEvent * _me ) override;
void mousePressEvent( QMouseEvent * _me ) override;
void mousePressEvent(QMouseEvent * me) override;
private:
void updateSize();
TextFloat(const QString & title, const QString & text, const QPixmap & pixmap);
QString m_title;
QString m_text;
QPixmap m_pixmap;
QLabel * m_pixmapLabel;
QLabel * m_titleLabel;
QLabel * m_textLabel;
};