LMMS
Loading...
Searching...
No Matches
lmms::gui::Knob Class Reference

#include <Knob.h>

Inheritance diagram for lmms::gui::Knob:
lmms::gui::FloatModelEditorBase lmms::gui::TypedModelView< FloatModel > lmms::gui::AutomatableModelView lmms::gui::ModelView lmms::gui::AudioFileProcessorWaveView::knob lmms::gui::CustomTextKnob lmms::gui::FreeBoyKnob lmms::gui::KickerKnob lmms::gui::KickerLargeKnob lmms::gui::OrganicKnob lmms::gui::Sf2Knob lmms::gui::SfxrKnob lmms::gui::TempoSyncKnob lmms::gui::TripleOscKnob lmms::gui::XpressiveKnob lmms::gui::gigKnob lmms::gui::sidKnob

Public Types

enum class  LabelRendering { WidgetFont , LegacyFixedFontSize }
 Determines how the label of the knob is rendered. More...
Public Types inherited from lmms::gui::FloatModelEditorBase
enum class  DirectionOfManipulation { Vertical , Horizontal }

Public Member Functions

 Knob (KnobType _knob_num, QWidget *_parent=nullptr, const QString &_name=QString())
 Construct a Knob with the given style and no label.
 Knob (KnobType knobNum, const QString &labelText, QWidget *parent=nullptr, LabelRendering labelRendering=LabelRendering::WidgetFont, const QString &name=QString())
 Construct a Knob with the given style and label text.
 Knob (KnobType knobNum, const QString &labelText, int labelPixelSize, QWidget *parent, const QString &name=QString())
 Constructs a knob with a label font in the pixel size.
 Knob (QWidget *_parent=nullptr, const QString &_name=QString())
 default ctor
 Knob (const Knob &other)=delete
const QString & getLabel () const
void setLabel (const QString &txt)
void setTotalAngle (float angle)
float innerRadius () const
void setInnerRadius (float r)
float outerRadius () const
void setOuterRadius (float r)
KnobType knobNum () const
void setknobNum (KnobType k)
QPointF centerPoint () const
float centerPointX () const
void setCenterPointX (float c)
float centerPointY () const
void setCenterPointY (float c)
float lineWidth () const
void setLineWidth (float w)
QColor outerColor () const
void setOuterColor (const QColor &c)
QColor textColor () const
void setTextColor (const QColor &c)
Public Member Functions inherited from lmms::gui::FloatModelEditorBase
 FloatModelEditorBase (DirectionOfManipulation directionOfManipulation=DirectionOfManipulation::Vertical, QWidget *_parent=nullptr, const QString &_name=QString())
 default ctor
 FloatModelEditorBase (const FloatModelEditorBase &other)=delete
void setHintText (const QString &txt_before, const QString &txt_after)
bool isVolumeKnob () const
void setVolumeKnob (const bool val)
Public Member Functions inherited from lmms::gui::TypedModelView< FloatModel >
 TypedModelView (Model *model, QWidget *_this)
FloatModelmodel ()
const FloatModelmodel () const
Public Member Functions inherited from lmms::gui::AutomatableModelView
 AutomatableModelView (Model *model, QWidget *_this)
 ~AutomatableModelView () override=default
AutomatableModelmodelUntyped ()
const AutomatableModelmodelUntyped () const
void setModel (Model *model, bool isOldModelValid=true) override
void unsetModel () override
template<typename T>
value () const
void setDescription (const QString &desc)
void setUnit (const QString &unit)
void addDefaultActions (QMenu *menu)
void setConversionFactor (float factor)
float getConversionFactor ()
Public Member Functions inherited from lmms::gui::ModelView
 ModelView (Model *model, QWidget *widget)
virtual ~ModelView ()
Modelmodel ()
const Modelmodel () const
template<class T>
T * castModel ()
template<class T>
const T * castModel () const

Protected Member Functions

void paintEvent (QPaintEvent *) override
void changeEvent (QEvent *ev) override
bool fixedFontSizeLabelRendering () const
void setFixedFontSizeLabelRendering ()
Protected Member Functions inherited from lmms::gui::FloatModelEditorBase
void contextMenuEvent (QContextMenuEvent *me) override
void dragEnterEvent (QDragEnterEvent *dee) override
void dropEvent (QDropEvent *de) override
void focusOutEvent (QFocusEvent *fe) override
void mousePressEvent (QMouseEvent *me) override
void mouseReleaseEvent (QMouseEvent *me) override
void mouseMoveEvent (QMouseEvent *me) override
void mouseDoubleClickEvent (QMouseEvent *me) override
void paintEvent (QPaintEvent *me) override
void wheelEvent (QWheelEvent *me) override
void enterEvent (QEnterEvent *) override
void leaveEvent (QEvent *event) override
virtual float getValue (const QPoint &p)
virtual QString displayValue () const
void doConnections () override
void showTextFloat (int msecBeforeDisplay, int msecDisplayTime)
void setPosition (const QPoint &p)
float pageSize () const
Protected Member Functions inherited from lmms::gui::ModelView
virtual void modelChanged ()
QWidget * widget ()

Properties

float innerRadius
float outerRadius
float centerPointX
float centerPointY
float lineWidth
QColor outerColor
QColor lineActiveColor
QColor lineInactiveColor
QColor arcActiveColor
QColor arcInactiveColor
KnobType knobNum
QColor textColor

Private Member Functions

void initUi (const QString &_name)
 to be called by ctors
void onKnobNumUpdated ()
 to be called when you updated m_knobNum
QLineF calculateLine (const QPointF &_mid, float _radius, float _innerRadius=1) const
void drawKnob (QPainter *_p)
void drawLabel (QPainter &p)
bool updateAngle ()
int angleFromValue (float value, float minValue, float maxValue, float totalAngle) const
void updateFixedSize ()

Private Attributes

QString m_label
bool m_fixedFontSizeLabelRendering = false
std::unique_ptr< QPixmap > m_knobPixmap
float m_totalAngle
int m_angle
QImage m_cache
QPointF m_centerPoint
float m_innerRadius
float m_outerRadius
float m_lineWidth
QColor m_outerColor
QColor m_lineActiveColor
QColor m_lineInactiveColor
QColor m_arcActiveColor
QColor m_arcInactiveColor
QColor m_textColor
KnobType m_knobNum

Additional Inherited Members

Signals inherited from lmms::gui::FloatModelEditorBase
void sliderPressed ()
void sliderReleased ()
void sliderMoved (float value)
Protected Attributes inherited from lmms::gui::FloatModelEditorBase
bool m_volumeKnob
FloatModel m_volumeRatio
QPoint m_lastMousePos
 mouse position in last mouseMoveEvent
float m_leftOver
bool m_buttonPressed
DirectionOfManipulation m_directionOfManipulation
Protected Attributes inherited from lmms::gui::AutomatableModelView
QString m_description
QString m_unit
float m_conversionFactor
Static Protected Attributes inherited from lmms::gui::FloatModelEditorBase
static SimpleTextFloats_textFloat = nullptr

Member Enumeration Documentation

◆ LabelRendering

Determines how the label of the knob is rendered.

Labels can be rendered using the font that is set for the knob or using a font with a fixed size which is determined by SMALL_FONT_SIZE.

Enumerator
WidgetFont 

Renders the label using the font that is set for the widget.

The space that's needed for the label is determined using the font metrics of the knob's font.

LegacyFixedFontSize 

Renders the labels in legacy mode. This uses a fixed font size and does not adhere to the font size that's set for the widget's font.

Deprecated
Do not use this mode in new code as it is considered deprecated and might be removed in the future.

Constructor & Destructor Documentation

◆ Knob() [1/5]

lmms::gui::Knob::Knob ( KnobType _knob_num,
QWidget * _parent = nullptr,
const QString & _name = QString() )

Construct a Knob with the given style and no label.

Parameters
_knob_numStyle of the knob
_parentParent widget
_nameObject name of the widget

◆ Knob() [2/5]

lmms::gui::Knob::Knob ( KnobType knobNum,
const QString & labelText,
QWidget * parent = nullptr,
LabelRendering labelRendering = LabelRendering::WidgetFont,
const QString & name = QString() )

Construct a Knob with the given style and label text.

Parameters
knobNumStyle of the knob
labelTextText for the label
parentParent widget
labelRenderingDetermines if the label uses the widget font or a font with a fixed size of 12 pixels (LegacyFixedFontSize). The default is to use the widget font.
nameObject name of the widget

◆ Knob() [3/5]

lmms::gui::Knob::Knob ( KnobType knobNum,
const QString & labelText,
int labelPixelSize,
QWidget * parent,
const QString & name = QString() )

Constructs a knob with a label font in the pixel size.

Parameters
knobNumStyle of the knob
labelTextText for the label
labelPixelSizePixel size for the label
parentParent widget
nameObject name of the widget

◆ Knob() [4/5]

lmms::gui::Knob::Knob ( QWidget * _parent = nullptr,
const QString & _name = QString() )

default ctor

◆ Knob() [5/5]

lmms::gui::Knob::Knob ( const Knob & other)
delete

Member Function Documentation

◆ angleFromValue()

int lmms::gui::Knob::angleFromValue ( float value,
float minValue,
float maxValue,
float totalAngle ) const
inlineprivate

◆ calculateLine()

QLineF lmms::gui::Knob::calculateLine ( const QPointF & _mid,
float _radius,
float _innerRadius = 1 ) const
private

◆ centerPoint()

QPointF lmms::gui::Knob::centerPoint ( ) const

◆ centerPointX()

float lmms::gui::Knob::centerPointX ( ) const

◆ centerPointY()

float lmms::gui::Knob::centerPointY ( ) const

◆ changeEvent()

void lmms::gui::Knob::changeEvent ( QEvent * ev)
overrideprotected

◆ drawKnob()

void lmms::gui::Knob::drawKnob ( QPainter * _p)
private

◆ drawLabel()

void lmms::gui::Knob::drawLabel ( QPainter & p)
private

◆ fixedFontSizeLabelRendering()

bool lmms::gui::Knob::fixedFontSizeLabelRendering ( ) const
inlineprotected

Affects how the label of the knob is rendered.

The default mode returns false. The height of the label text is taken into account when a new fixed size is computed for the Knob. When the label text is painted the descent of the font is used to compute the base line. The default mode returns false.

Enabling fixed font size rendering mode leads to the following behavior:

  • The height of the label is not taken into account when the new fixed height of the Knob is computed. Instead a fixed size of 10 is added for the label.
  • When the knob is painted the baseline of the font is always set to 2 pixels away from the lower side of the Knob's rectangle.
  • The label is always rendered with a size of SMALL_FONT_SIZE.

◆ getLabel()

const QString & lmms::gui::Knob::getLabel ( ) const

◆ initUi()

void lmms::gui::Knob::initUi ( const QString & _name)
private

to be called by ctors

◆ innerRadius()

float lmms::gui::Knob::innerRadius ( ) const

◆ knobNum()

KnobType lmms::gui::Knob::knobNum ( ) const

◆ lineWidth()

float lmms::gui::Knob::lineWidth ( ) const

◆ onKnobNumUpdated()

void lmms::gui::Knob::onKnobNumUpdated ( )
private

to be called when you updated m_knobNum

◆ outerColor()

QColor lmms::gui::Knob::outerColor ( ) const

◆ outerRadius()

float lmms::gui::Knob::outerRadius ( ) const

◆ paintEvent()

void lmms::gui::Knob::paintEvent ( QPaintEvent * )
overrideprotected

◆ setCenterPointX()

void lmms::gui::Knob::setCenterPointX ( float c)

◆ setCenterPointY()

void lmms::gui::Knob::setCenterPointY ( float c)

◆ setFixedFontSizeLabelRendering()

void lmms::gui::Knob::setFixedFontSizeLabelRendering ( )
protected

Set the button to legacy rendering mode which uses a fixed font size and that does not take the size of the widget's font into account.

This can be thought of as a legacy mode which reinstates the old behavior of the knob.

See also
fixedFontSizeLabelRendering().

◆ setInnerRadius()

void lmms::gui::Knob::setInnerRadius ( float r)

◆ setknobNum()

void lmms::gui::Knob::setknobNum ( KnobType k)

◆ setLabel()

void lmms::gui::Knob::setLabel ( const QString & txt)

◆ setLineWidth()

void lmms::gui::Knob::setLineWidth ( float w)

◆ setOuterColor()

void lmms::gui::Knob::setOuterColor ( const QColor & c)

◆ setOuterRadius()

void lmms::gui::Knob::setOuterRadius ( float r)

◆ setTextColor()

void lmms::gui::Knob::setTextColor ( const QColor & c)

◆ setTotalAngle()

void lmms::gui::Knob::setTotalAngle ( float angle)

◆ textColor()

QColor lmms::gui::Knob::textColor ( ) const

◆ updateAngle()

bool lmms::gui::Knob::updateAngle ( )
private

◆ updateFixedSize()

void lmms::gui::Knob::updateFixedSize ( )
private

Member Data Documentation

◆ m_angle

int lmms::gui::Knob::m_angle
private

◆ m_arcActiveColor

QColor lmms::gui::Knob::m_arcActiveColor
private

◆ m_arcInactiveColor

QColor lmms::gui::Knob::m_arcInactiveColor
private

◆ m_cache

QImage lmms::gui::Knob::m_cache
private

◆ m_centerPoint

QPointF lmms::gui::Knob::m_centerPoint
private

◆ m_fixedFontSizeLabelRendering

bool lmms::gui::Knob::m_fixedFontSizeLabelRendering = false
private

◆ m_innerRadius

float lmms::gui::Knob::m_innerRadius
private

◆ m_knobNum

KnobType lmms::gui::Knob::m_knobNum
private

◆ m_knobPixmap

std::unique_ptr<QPixmap> lmms::gui::Knob::m_knobPixmap
private

◆ m_label

QString lmms::gui::Knob::m_label
private

◆ m_lineActiveColor

QColor lmms::gui::Knob::m_lineActiveColor
private

◆ m_lineInactiveColor

QColor lmms::gui::Knob::m_lineInactiveColor
private

◆ m_lineWidth

float lmms::gui::Knob::m_lineWidth
private

◆ m_outerColor

QColor lmms::gui::Knob::m_outerColor
private

◆ m_outerRadius

float lmms::gui::Knob::m_outerRadius
private

◆ m_textColor

QColor lmms::gui::Knob::m_textColor
private

◆ m_totalAngle

float lmms::gui::Knob::m_totalAngle
private

Property Documentation

◆ arcActiveColor

QColor lmms::gui::Knob::arcActiveColor

◆ arcInactiveColor

QColor lmms::gui::Knob::arcInactiveColor

◆ centerPointX

float lmms::gui::Knob::centerPointX
readwrite

◆ centerPointY

float lmms::gui::Knob::centerPointY
readwrite

◆ innerRadius

float lmms::gui::Knob::innerRadius
readwrite

◆ knobNum

KnobType lmms::gui::Knob::knobNum
readwrite

◆ lineActiveColor

QColor lmms::gui::Knob::lineActiveColor

◆ lineInactiveColor

QColor lmms::gui::Knob::lineInactiveColor

◆ lineWidth

float lmms::gui::Knob::lineWidth
readwrite

◆ outerColor

QColor lmms::gui::Knob::outerColor
readwrite

◆ outerRadius

float lmms::gui::Knob::outerRadius
readwrite

◆ textColor

QColor lmms::gui::Knob::textColor
readwrite

The documentation for this class was generated from the following files: