Skip to content

Commit

Permalink
Add tooltips to fxmixer faders
Browse files Browse the repository at this point in the history
Added tooltips to show the actual value when moving the fader handle.
This works mostly like the same feature we already have for the volume
knobs. Depending on settings the value is shown in a range between
0% to 200% or -inf/-34dBV to 6.02 dBV. Again that's the same as for the
volume knob. Value range could be adjusted easily if necessary.

Closes #3305914.

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
  • Loading branch information
rymr authored and tobydox committed Jun 23, 2011
1 parent 8f9d90d commit ee0f6cc
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/fader.h
Expand Up @@ -53,6 +53,8 @@

#include "AutomatableModelView.h"

class textFloat;


class fader : public QWidget, public FloatModelView
{
Expand All @@ -75,9 +77,18 @@ class fader : public QWidget, public FloatModelView
virtual void contextMenuEvent( QContextMenuEvent * _me );
virtual void mousePressEvent( QMouseEvent *ev );
virtual void mouseMoveEvent( QMouseEvent *ev );
virtual void mouseReleaseEvent( QMouseEvent * _me );
virtual void wheelEvent( QWheelEvent *ev );
virtual void paintEvent( QPaintEvent *ev );

inline uint knob_y() const
{
float fRange = m_model->maxValue() - m_model->minValue();
float realVal = m_model->value() - m_model->minValue();
// uint knob_y = (uint)( 116.0 - ( 86.0 * ( m_model->value() / fRange ) ) );
return (uint)( 116.0 - ( 86.0 * ( realVal / fRange ) ) );
}

FloatModel * m_model;

float m_fPeakValue_L;
Expand All @@ -88,6 +99,10 @@ class fader : public QWidget, public FloatModelView
QPixmap m_back;
QPixmap m_leds;
QPixmap m_knob;

static textFloat * s_textFloat;
void updateTextFloat();

} ;


Expand Down
33 changes: 33 additions & 0 deletions src/gui/widgets/fader.cpp
Expand Up @@ -53,9 +53,13 @@
#include "embed.h"
#include "engine.h"
#include "caption_menu.h"
#include "config_mgr.h"
#include "text_float.h"
#include "MainWindow.h"


textFloat * fader::s_textFloat = NULL;


fader::fader( FloatModel * _model, const QString & _name, QWidget * _parent ) :
QWidget( _parent ),
Expand All @@ -69,6 +73,10 @@ fader::fader( FloatModel * _model, const QString & _name, QWidget * _parent ) :
m_leds( embed::getIconPixmap( "fader_leds" ) ),
m_knob( embed::getIconPixmap( "fader_knob" ) )
{
if( s_textFloat == NULL )
{
s_textFloat = new textFloat;
}
setAccessibleName( _name );
setAttribute( Qt::WA_OpaquePaintEvent, true );
setMinimumSize( 23, 116 );
Expand Down Expand Up @@ -105,6 +113,8 @@ void fader::mouseMoveEvent( QMouseEvent *ev )
fVal = fVal + m_model->minValue();

m_model->setValue( fVal );

updateTextFloat();
}


Expand All @@ -115,6 +125,9 @@ void fader::mousePressEvent( QMouseEvent * _me )
if( _me->button() == Qt::LeftButton &&
! ( _me->modifiers() & Qt::ControlModifier ) )
{
updateTextFloat();
s_textFloat->show();

mouseMoveEvent( _me );
_me->accept();
}
Expand All @@ -126,6 +139,11 @@ void fader::mousePressEvent( QMouseEvent * _me )



void fader::mouseReleaseEvent( QMouseEvent * _me )
{
s_textFloat->hide();
}


void fader::wheelEvent ( QWheelEvent *ev )
{
Expand All @@ -139,6 +157,8 @@ void fader::wheelEvent ( QWheelEvent *ev )
{
m_model->incValue( -5 );
}
updateTextFloat();
s_textFloat->setVisibilityTimeOut( 1000 );
}


Expand Down Expand Up @@ -182,6 +202,19 @@ void fader::setPeak_R( float fPeak )
}
}

void fader::updateTextFloat()
{
if( configManager::inst()->value( "app", "displaydbv" ).toInt() )
{
s_textFloat->setText( QString("Volume: %1 dBV").
arg( 20.0 * log10( model()->value() ), 3, 'f', 2 ) );
}
else
{
s_textFloat->setText( QString("Volume: %1 %").arg( m_model->value() * 100 ) );
}
s_textFloat->moveGlobal( this, QPoint( width() - m_knob.width() - 5, knob_y() - 46 ) );
}



Expand Down

0 comments on commit ee0f6cc

Please sign in to comment.