From 2877d9c47fcad5ae3258a3e05f1a0a457f02cb22 Mon Sep 17 00:00:00 2001 From: Paul Giblock Date: Wed, 28 Jan 2009 08:44:42 +0000 Subject: [PATCH] Begin theming widgets with LmmsStyle git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1978 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 17 +++ src/gui/fx_mixer_view.cpp | 20 +-- src/gui/widgets/combobox.cpp | 12 +- src/gui/widgets/controller_view.cpp | 27 ++-- src/gui/widgets/effect_view.cpp | 12 +- src/gui/widgets/envelope_and_lfo_view.cpp | 150 +++++++++++----------- src/gui/widgets/graph.cpp | 39 +++--- src/gui/widgets/lcd_spinbox.cpp | 26 ++-- src/gui/widgets/led_checkbox.cpp | 4 +- src/gui/widgets/project_notes.cpp | 8 +- src/gui/widgets/text_float.cpp | 9 +- src/gui/widgets/visualization_widget.cpp | 14 +- 12 files changed, 173 insertions(+), 165 deletions(-) diff --git a/ChangeLog b/ChangeLog index 377710218..80e7205b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,23 @@ * src/gui/widgets/effect_rack_view.cpp: Prevent Horizontal scroll bars from appearing in some cases + * src/gui/piano_roll.cpp: + * src/gui/widgets/visualization_widget.cpp: + Plug memory leaks + + * src/gui/fx_mixer_view.cpp: + * src/gui/widgets/combobox.cpp: + * srg/gui/widgets/graph.cpp: + * src/gui/widgets/visualization_widget.cpp: + * src/gui/widgets/led_checkbox.cpp: + * src/gui/widgets/envelope_and_lfo_view.cpp: + * src/gui/widgets/lcd_spinbox.cpp: + * src/gui/widgets/text_float.cpp: + * src/gui/widgets/controller_view.cpp: + * src/gui/widgets/effect_view.cpp: + * src/gui/widgets/project_notes.cpp: + Begin themeing widgets with the new LmmsStyle interface + 2009-01-26 Paul Giblock * src/tracks/bb_track.cpp: diff --git a/src/gui/fx_mixer_view.cpp b/src/gui/fx_mixer_view.cpp index 3488c555d..12c720576 100644 --- a/src/gui/fx_mixer_view.cpp +++ b/src/gui/fx_mixer_view.cpp @@ -61,20 +61,8 @@ public: virtual void paintEvent( QPaintEvent * ) { - QPainter p( this ); - p.fillRect( rect(), QColor( 72, 76, 88 ) ); - p.setPen( QColor( 40, 42, 48 ) ); - p.drawRect( 0, 0, width()-2, height()-2 ); - p.setPen( QColor( 108, 114, 132 ) ); - p.drawRect( 1, 1, width()-2, height()-2 ); - p.setPen( QColor( 20, 24, 32 ) ); - p.drawRect( 0, 0, width()-1, height()-1 ); - - p.rotate( -90 ); - p.setPen( m_mv->currentFxLine() == this ? - QColor( 0, 255, 0 ) : Qt::white ); - p.setFont( pointSizeF( font(), 7.5f ) ); - p.drawText( -90, 20, m_name ); + engine::getLmmsStyle()->drawFxLine( &QPainter(this), + this, m_name, m_mv->currentFxLine() == this ); } virtual void mousePressEvent( QMouseEvent * ) @@ -115,8 +103,8 @@ fxMixerView::fxMixerView() : m->setHook( this ); QPalette pal = palette(); - pal.setColor( QPalette::Background, QColor( 72, 76, 88 ) ); - setPalette( pal ); + //pal.setColor( QPalette::Background, QColor( 72, 76, 88 ) ); + //setPalette( pal ); setAutoFillBackground( true ); setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ); diff --git a/src/gui/widgets/combobox.cpp b/src/gui/widgets/combobox.cpp index 3110acbfb..3661b274c 100644 --- a/src/gui/widgets/combobox.cpp +++ b/src/gui/widgets/combobox.cpp @@ -4,7 +4,8 @@ * combobox.cpp - implementation of LMMS-combobox * * Copyright (c) 2006-2008 Tobias Doerffel - * + * Copyright (c) 2008-2009 Paul Giblock + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -23,7 +24,7 @@ * Boston, MA 02110-1301 USA. * */ - + #include "combobox.h" @@ -172,9 +173,10 @@ void comboBox::paintEvent( QPaintEvent * _pe ) QPainter p( this ); p.fillRect( 2, 2, width()-2, height()-4, *s_background ); - + QColor shadow = palette().shadow().color(); QColor highlight = palette().highlight().color(); + QColor text = palette().text().color(); shadow.setAlpha( 124 ); highlight.setAlpha( 124 ); @@ -196,7 +198,7 @@ void comboBox::paintEvent( QPaintEvent * _pe ) style()->drawPrimitive( QStyle::PE_Frame, &opt, &p, this ); QPixmap * arrow = m_pressed ? s_arrowSelected : s_arrow; - + p.drawPixmap( width() - CB_ARROW_BTN_WIDTH + 5, 4, *arrow ); @@ -221,7 +223,7 @@ void comboBox::paintEvent( QPaintEvent * _pe ) const int y = ( height()+p.fontMetrics().height() ) /2; p.setPen( QColor( 64, 64, 64 ) ); p.drawText( tx+1, y-3, model()->currentText() ); - p.setPen( QColor( 224, 224, 224 ) ); + p.setPen( text ); p.drawText( tx, y-4, model()->currentText() ); } } diff --git a/src/gui/widgets/controller_view.cpp b/src/gui/widgets/controller_view.cpp index 86a8062a2..b75239f85 100644 --- a/src/gui/widgets/controller_view.cpp +++ b/src/gui/widgets/controller_view.cpp @@ -4,7 +4,7 @@ * controller_view.cpp - view-component for an controller * * Copyright (c) 2008 Paul Giblock - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -57,20 +57,17 @@ controllerView::controllerView( controller * _model, QWidget * _parent ) : setAttribute( Qt::WA_OpaquePaintEvent, TRUE ); - QPushButton * ctls_btn = new QPushButton( tr( "Controls" ), - this ); - + QPushButton * ctls_btn = new QPushButton( tr( "Controls" ), this ); + QFont f = ctls_btn->font(); ctls_btn->setFont( pointSize<7>( f ) ); ctls_btn->setGeometry( 140, 2, 50, 14 ); - connect( ctls_btn, SIGNAL( clicked() ), - this, SLOT( editControls() ) ); + connect( ctls_btn, SIGNAL( clicked() ), this, SLOT( editControls() ) ); m_controllerDlg = getController()->createDialog( engine::getMainWindow()->workspace() ); - m_subWindow = engine::getMainWindow()->workspace()->addSubWindow( - m_controllerDlg ); - + m_subWindow = engine::getMainWindow()->workspace()->addSubWindow( m_controllerDlg ); + Qt::WindowFlags flags = m_subWindow->windowFlags(); flags |= Qt::MSWindowsFixedSizeDialogHint; flags &= ~Qt::WindowMaximizeButtonHint; @@ -79,13 +76,13 @@ controllerView::controllerView( controller * _model, QWidget * _parent ) : m_subWindow->setWindowIcon( m_controllerDlg->windowIcon() ); - connect( m_controllerDlg, SIGNAL( closed() ), - this, SLOT( closeControls() ) ); + connect( m_controllerDlg, SIGNAL( closed() ), + this, SLOT( closeControls() ) ); m_subWindow->hide(); setWhatsThis( tr( "Controllers are able to automate the value of a knob, " - "slider, and other controls." ) ); + "slider, and other controls." ) ); setModel( _model ); } @@ -146,11 +143,11 @@ void controllerView::paintEvent( QPaintEvent * ) p.setPen( QColor( 64, 64, 64 ) ); p.drawText( 7, 13, c->displayName() ); - p.setPen( Qt::white ); + p.setPen( palette().text().color() ); p.drawText( 6, 12, c->displayName() ); - f.setBold( FALSE ); - p.setFont( f ); + f.setBold( FALSE ); + p.setFont( f ); p.drawText( 8, 26, c->name() ); } diff --git a/src/gui/widgets/effect_view.cpp b/src/gui/widgets/effect_view.cpp index 984d10f42..4a12b7ece 100644 --- a/src/gui/widgets/effect_view.cpp +++ b/src/gui/widgets/effect_view.cpp @@ -5,7 +5,7 @@ * * Copyright (c) 2006-2007 Danny McRae * Copyright (c) 2007-2008 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -76,7 +76,7 @@ effectView::effectView( effect * _model, QWidget * _parent ) : m_autoQuit->setLabel( tr( "DECAY" ) ); m_autoQuit->move( 60, 5 ); m_autoQuit->setHintText( tr( "Time:" ) + " ", "ms" ); - m_autoQuit->setWhatsThis( tr( + m_autoQuit->setWhatsThis( tr( "The Decay knob controls how many buffers of silence must pass before the " "plugin stops processing. Smaller values will reduce the CPU overhead but " "run the risk of clipping the tail on delay and reverb effects." ) ); @@ -86,7 +86,7 @@ effectView::effectView( effect * _model, QWidget * _parent ) : m_gate->setLabel( tr( "GATE" ) ); m_gate->move( 93, 5 ); m_gate->setHintText( tr( "Gate:" ) + " ", "" ); - m_gate->setWhatsThis( tr( + m_gate->setWhatsThis( tr( "The Gate knob controls the signal level that is considered to be 'silence' " "while deciding when to stop processing signals." ) ); @@ -98,7 +98,7 @@ effectView::effectView( effect * _model, QWidget * _parent ) : QFont f = ctls_btn->font(); ctls_btn->setFont( pointSize<7>( f ) ); ctls_btn->setGeometry( 140, 14, 50, 20 ); - connect( ctls_btn, SIGNAL( clicked() ), + connect( ctls_btn, SIGNAL( clicked() ), this, SLOT( editControls() ) ); } @@ -116,7 +116,7 @@ effectView::effectView( effect * _model, QWidget * _parent ) : m_subWindow->hide(); - setWhatsThis( tr( + setWhatsThis( tr( "Effect plugins function as a chained series of effects where the signal will " "be processed from top to bottom.\n\n" @@ -253,7 +253,7 @@ void effectView::paintEvent( QPaintEvent * ) p.setPen( QColor( 64, 64, 64 ) ); p.drawText( 6, 55, getModel()->displayName() ); - p.setPen( Qt::white ); + p.setPen( palette().text().color() ); p.drawText( 5, 54, getModel()->displayName() ); } diff --git a/src/gui/widgets/envelope_and_lfo_view.cpp b/src/gui/widgets/envelope_and_lfo_view.cpp index 21d364795..213245a5c 100644 --- a/src/gui/widgets/envelope_and_lfo_view.cpp +++ b/src/gui/widgets/envelope_and_lfo_view.cpp @@ -5,7 +5,7 @@ * tab of channel-window * * Copyright (c) 2004-2008 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -59,26 +59,25 @@ const int ENV_GRAPH_X = 6; const int ENV_GRAPH_Y = 6; const int ENV_KNOBS_Y = 43; -const int ENV_KNOBS_LBL_Y = ENV_KNOBS_Y+35; +const int ENV_KNOBS_LBL_Y = ENV_KNOBS_Y + 35; const int KNOB_X_SPACING = 32; const int PREDELAY_KNOB_X = 6; -const int ATTACK_KNOB_X = PREDELAY_KNOB_X+KNOB_X_SPACING; -const int HOLD_KNOB_X = ATTACK_KNOB_X+KNOB_X_SPACING; -const int DECAY_KNOB_X = HOLD_KNOB_X+KNOB_X_SPACING; -const int SUSTAIN_KNOB_X = DECAY_KNOB_X+KNOB_X_SPACING; -const int RELEASE_KNOB_X = SUSTAIN_KNOB_X+KNOB_X_SPACING; -const int AMOUNT_KNOB_X = RELEASE_KNOB_X+KNOB_X_SPACING; +const int ATTACK_KNOB_X = PREDELAY_KNOB_X + KNOB_X_SPACING; +const int HOLD_KNOB_X = ATTACK_KNOB_X + KNOB_X_SPACING; +const int DECAY_KNOB_X = HOLD_KNOB_X + KNOB_X_SPACING; +const int SUSTAIN_KNOB_X = DECAY_KNOB_X + KNOB_X_SPACING; +const int RELEASE_KNOB_X = SUSTAIN_KNOB_X + KNOB_X_SPACING; +const int AMOUNT_KNOB_X = RELEASE_KNOB_X + KNOB_X_SPACING; const float TIME_UNIT_WIDTH = 36.0; - const int LFO_GRAPH_X = 6; -const int LFO_GRAPH_Y = ENV_KNOBS_LBL_Y+14; -const int LFO_KNOB_Y = LFO_GRAPH_Y-2; +const int LFO_GRAPH_Y = ENV_KNOBS_LBL_Y + 14; +const int LFO_KNOB_Y = LFO_GRAPH_Y - 2; const int LFO_PREDELAY_KNOB_X = LFO_GRAPH_X + 100; -const int LFO_ATTACK_KNOB_X = LFO_PREDELAY_KNOB_X+KNOB_X_SPACING; -const int LFO_SPEED_KNOB_X = LFO_ATTACK_KNOB_X+KNOB_X_SPACING; -const int LFO_AMOUNT_KNOB_X = LFO_SPEED_KNOB_X+KNOB_X_SPACING; +const int LFO_ATTACK_KNOB_X = LFO_PREDELAY_KNOB_X + KNOB_X_SPACING; +const int LFO_SPEED_KNOB_X = LFO_ATTACK_KNOB_X + KNOB_X_SPACING; +const int LFO_AMOUNT_KNOB_X = LFO_SPEED_KNOB_X + KNOB_X_SPACING; const int LFO_SHAPES_X = LFO_GRAPH_X;//PREDELAY_KNOB_X; const int LFO_SHAPES_Y = LFO_GRAPH_Y + 50; @@ -428,97 +427,98 @@ void envelopeAndLFOView::paintEvent( QPaintEvent * ) p.setFont( pointSize<8>( p.font() ) ); + LmmsStyle * style = engine::getLmmsStyle(); + QColor lineColor = style->color(LmmsStyle::StandardGraphLine); const float gray_amount = 1.0f - fabsf( m_amountKnob->value() ); - p.setPen( QPen( QColor( static_cast( 96 * gray_amount ), - static_cast( 255 - 159 * gray_amount ), - static_cast( 128 - 32 * gray_amount ) ), - 2 ) ); + p.setPen( QPen( QColor::fromHsvF( + lineColor.hueF(), + lineColor.saturationF() * gray_amount, + lineColor.valueF() * (0.5+gray_amount*0.5) ), 2 ) ); - const QColor end_points_color( 0xFF, 0xBF, 0x22 ); - const QColor end_points_bg_color( 0, 0, 2 ); + const QColor endPointsColor = style->color( LmmsStyle::StandardGraphHandle ); + const QColor endPointsBorderColor = style->color(LmmsStyle::StandardGraphHandleBorder ); + + const int yBase = ENV_GRAPH_Y + s_envGraph->height() - 3; + const int availHeight = s_envGraph->height() - 6; - const int y_base = ENV_GRAPH_Y + s_envGraph->height() - 3; - const int avail_height = s_envGraph->height() - 6; - int x1 = ENV_GRAPH_X + 2 + static_cast( m_predelayKnob->value() * TIME_UNIT_WIDTH ); int x2 = x1 + static_cast( m_attackKnob->value() * TIME_UNIT_WIDTH ); - p.drawLine( x1, y_base, x2, y_base - avail_height ); - p.fillRect( x1 - 1, y_base - 2, 4, 4, end_points_bg_color ); - p.fillRect( x1, y_base - 1, 2, 2, end_points_color ); + p.drawLine( x1, yBase, x2, yBase - availHeight ); + p.fillRect( x1 - 1, yBase - 2, 4, 4, endPointsBorderColor ); + p.fillRect( x1, yBase - 1, 2, 2, endPointsColor ); x1 = x2; x2 = x1 + static_cast( m_holdKnob->value() * TIME_UNIT_WIDTH ); - p.drawLine( x1, y_base - avail_height, x2, y_base - avail_height ); - p.fillRect( x1 - 1, y_base - 2 - avail_height, 4, 4, - end_points_bg_color ); - p.fillRect( x1, y_base-1-avail_height, 2, 2, end_points_color ); + p.drawLine( x1, yBase - availHeight, x2, yBase - availHeight ); + p.fillRect( x1 - 1, yBase - 2 - availHeight, 4, 4, + endPointsBorderColor ); + p.fillRect( x1, yBase-1-availHeight, 2, 2, endPointsColor ); x1 = x2; x2 = x1 + static_cast( ( m_decayKnob->value() * m_sustainKnob->value() ) * TIME_UNIT_WIDTH ); - p.drawLine( x1, y_base-avail_height, x2, static_cast( y_base - - avail_height + - m_sustainKnob->value() * avail_height ) ); - p.fillRect( x1 - 1, y_base - 2 - avail_height, 4, 4, - end_points_bg_color ); - p.fillRect( x1, y_base - 1 - avail_height, 2, 2, end_points_color ); + p.drawLine( x1, yBase-availHeight, x2, static_cast( yBase - + availHeight + + m_sustainKnob->value() * availHeight ) ); + p.fillRect( x1 - 1, yBase - 2 - availHeight, 4, 4, + endPointsBorderColor ); + p.fillRect( x1, yBase - 1 - availHeight, 2, 2, endPointsColor ); x1 = x2; x2 = x1 + static_cast( m_releaseKnob->value() * TIME_UNIT_WIDTH ); - p.drawLine( x1, static_cast( y_base - avail_height + + p.drawLine( x1, static_cast( yBase - availHeight + m_sustainKnob->value() * - avail_height ), x2, y_base ); - p.fillRect( x1-1, static_cast( y_base - avail_height + + availHeight ), x2, yBase ); + p.fillRect( x1-1, static_cast( yBase - availHeight + m_sustainKnob->value() * - avail_height ) - 2, 4, 4, - end_points_bg_color ); - p.fillRect( x1, static_cast( y_base - avail_height + + availHeight ) - 2, 4, 4, + endPointsBorderColor ); + p.fillRect( x1, static_cast( yBase - availHeight + m_sustainKnob->value() * - avail_height ) - 1, 2, 2, - end_points_color ); - p.fillRect( x2 - 1, y_base - 2, 4, 4, end_points_bg_color ); - p.fillRect( x2, y_base - 1, 2, 2, end_points_color ); + availHeight ) - 1, 2, 2, + endPointsColor ); + p.fillRect( x2 - 1, yBase - 2, 4, 4, endPointsBorderColor ); + p.fillRect( x2, yBase - 1, 2, 2, endPointsColor ); - int LFO_GRAPH_W = s_lfoGraph->width() - 6; // substract border - int LFO_GRAPH_H = s_lfoGraph->height() - 6; // substract border - int graph_x_base = LFO_GRAPH_X + 3; - int graph_y_base = LFO_GRAPH_Y + 3 + LFO_GRAPH_H / 2; + int lfoGraphWidth = s_lfoGraph->width() - 6; // substract border + int lfoGraphHeight = s_lfoGraph->height() - 6; // substract border + int graphXBase = LFO_GRAPH_X + 3; + int graphYBase = LFO_GRAPH_Y + 3 + lfoGraphHeight / 2; - const float frames_for_graph = SECS_PER_LFO_OSCILLATION * + const float framesForGraph = SECS_PER_LFO_OSCILLATION * engine::getMixer()->baseSampleRate() / 10; - const float lfo_gray_amount = 1.0f - fabsf( m_lfoAmountKnob->value() ); - p.setPen( QPen( QColor( static_cast( 96 * lfo_gray_amount ), - static_cast( 255 - 159 * lfo_gray_amount ), - static_cast( 128 - 32 * - lfo_gray_amount ) ), - 1.5 ) ); + const float lfoGrayAmount = 1.0f - fabsf( m_lfoAmountKnob->value() ); + p.setPen( QPen( QColor::fromHsvF( + lineColor.hueF(), + lineColor.saturationF() * lfoGrayAmount, + lineColor.valueF() * (0.5+lfoGrayAmount*0.5) ), 1.5 ) ); - float osc_frames = m_params->m_lfoOscillationFrames; + float oscFrames = m_params->m_lfoOscillationFrames; if( m_params->m_x100Model.value() ) { - osc_frames *= 100.0f; + oscFrames *= 100.0f; } - float old_y = 0; - for( int x = 0; x <= LFO_GRAPH_W; ++x ) + float oldY = 0; + for( int x = 0; x <= lfoGraphWidth; ++x ) { float val = 0.0; - float cur_sample = x * frames_for_graph / LFO_GRAPH_W; - if( static_cast( cur_sample ) > + float curSample = x * framesForGraph / lfoGraphWidth; + if( static_cast( curSample ) > m_params->m_lfoPredelayFrames ) { - float phase = ( cur_sample -= + float phase = ( curSample -= m_params->m_lfoPredelayFrames ) / - osc_frames; + oscFrames; switch( m_params->m_lfoWaveModel.value() ) { case envelopeAndLFOParameters::SineWave: @@ -538,27 +538,27 @@ void envelopeAndLFOView::paintEvent( QPaintEvent * ) val = m_params->m_userWave. userWaveSample( phase ); } - if( static_cast( cur_sample ) <= + if( static_cast( curSample ) <= m_params->m_lfoAttackFrames ) { - val *= cur_sample / m_params->m_lfoAttackFrames; + val *= curSample / m_params->m_lfoAttackFrames; } } - float cur_y = -LFO_GRAPH_H / 2.0f * val; - p.drawLine( QLineF( graph_x_base + x - 1, graph_y_base + old_y, - graph_x_base + x, - graph_y_base + cur_y ) ); - old_y = cur_y; + float curY = -lfoGraphHeight / 2.0f * val; + p.drawLine( QLineF( graphXBase + x - 1, graphYBase + oldY, + graphXBase + x, + graphYBase + curY ) ); + oldY = curY; } - p.setPen( QColor( 255, 192, 0 ) ); - int ms_per_osc = static_cast( SECS_PER_LFO_OSCILLATION * + p.setPen( endPointsColor ); + int msPerOsc = static_cast( SECS_PER_LFO_OSCILLATION * m_lfoSpeedKnob->value() * 1000.0f ); p.drawText( LFO_GRAPH_X + 4, LFO_GRAPH_Y + s_lfoGraph->height() - 6, tr( "ms/LFO:" ) ); p.drawText( LFO_GRAPH_X + 52, LFO_GRAPH_Y + s_lfoGraph->height() - 6, - QString::number( ms_per_osc ) ); + QString::number( msPerOsc ) ); } diff --git a/src/gui/widgets/graph.cpp b/src/gui/widgets/graph.cpp index 5a5299cc9..a86657aa0 100644 --- a/src/gui/widgets/graph.cpp +++ b/src/gui/widgets/graph.cpp @@ -2,7 +2,7 @@ * graph.cpp - a QT widget for displaying and manipulating waveforms * * Copyright (c) 2006-2007 Andreas Brandmaier - * 2008 Paul Giblock + * Copyright (c) 2008-2009 Paul Giblock * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -32,6 +32,7 @@ #include "string_pair_drag.h" #include "sample_buffer.h" #include "oscillator.h" +#include "engine.h" //#include //#include @@ -41,12 +42,12 @@ using namespace std; graph::graph( QWidget * _parent, graphStyle _style ) : QWidget( _parent ), - /* TODO: size, background? */ + /* TODO: size, background? */ modelView( new graphModel( -1.0, 1.0, 128, NULL, TRUE ), this ), m_graphStyle( _style ) { m_mouseDown = false; - m_graphColor = QColor( 0xFF, 0xAA, 0x00 ); + m_graphColor = engine::getLmmsStyle()->color(LmmsStyle::StandardGraphLine); resize( 132, 104 ); setAcceptDrops( TRUE ); @@ -81,7 +82,7 @@ void graph::setGraphColor( QColor _graphcol ) /* void graph::loadSampleFromFile( const QString & _filename ) { - + int i; // zero sample_shape @@ -89,7 +90,7 @@ void graph::loadSampleFromFile( const QString & _filename ) { samplePointer[i] = 0; } - + // load user shape sampleBuffer buffer( _filename ); @@ -213,7 +214,7 @@ void graph::mouseReleaseEvent( QMouseEvent * _me ) setCursor( Qt::CrossCursor ); update(); } -} +} @@ -242,15 +243,15 @@ void graph::paintEvent( QPaintEvent * ) for( int i=0; i < length; i++ ) { // Needs to be rewritten - p.drawLine(2+static_cast(i*xscale), + p.drawLine(2+static_cast(i*xscale), 2+static_cast( ( (*samps)[i] - maxVal ) * yscale ), - 2+static_cast((i+1)*xscale), + 2+static_cast((i+1)*xscale), 2+static_cast( ( (*samps)[i+1] - maxVal ) * yscale ) ); } // Draw last segment wrapped around - p.drawLine(2+static_cast(length*xscale), + p.drawLine(2+static_cast(length*xscale), 2+static_cast( ( (*samps)[length] - maxVal ) * yscale ), width()-2, 2+static_cast( ( (*samps)[0] - maxVal ) * yscale ) ); @@ -262,19 +263,19 @@ void graph::paintEvent( QPaintEvent * ) case graph::NearestStyle: for( int i=0; i < length; i++ ) { - p.drawLine(2+static_cast(i*xscale), + p.drawLine(2+static_cast(i*xscale), 2+static_cast( ( (*samps)[i] - maxVal ) * yscale ), - 2+static_cast((i+1)*xscale), + 2+static_cast((i+1)*xscale), 2+static_cast( ( (*samps)[i] - maxVal ) * yscale ) ); - p.drawLine(2+static_cast((i+1)*xscale), + p.drawLine(2+static_cast((i+1)*xscale), 2+static_cast( ( (*samps)[i] - maxVal ) * yscale ), - 2+static_cast((i+1)*xscale), + 2+static_cast((i+1)*xscale), 2+static_cast( ( (*samps)[i+1] - maxVal ) * yscale ) ); } - p.drawLine(2+static_cast(length*xscale), + p.drawLine(2+static_cast(length*xscale), 2+static_cast( ( (*samps)[length] - maxVal ) * yscale ), width()-2, 2+static_cast( ( (*samps)[length] - maxVal ) * yscale ) ); @@ -286,10 +287,10 @@ void graph::paintEvent( QPaintEvent * ) // draw Pointer - if( m_mouseDown ) + if( m_mouseDown ) { QPoint cursor = mapFromGlobal( QCursor::pos() ); - p.setPen( QColor( 0xAA, 0xFF, 0x00, 0x70 ) ); + p.setPen( engine::getLmmsStyle()->color(LmmsStyle::StandardGraphCrosshair) ); p.drawLine( 2, cursor.y(), width()-2, cursor.y() ); p.drawLine( cursor.x(), 2, cursor.x(), height()-2 ); } @@ -374,7 +375,7 @@ void graphModel::setRange( float _min, float _max ) if( !m_samples.isEmpty() ) { - // Trim existing values + // Trim existing values for( int i=0; i < length(); i++ ) { m_samples[i] = fmaxf( _min, fminf( m_samples[i], _max ) ); @@ -498,7 +499,7 @@ void graphModel::smooth( void ) m_samples[0] = ( temp[0] + temp[length()-1] ) * 0.5f; for ( int i=1; i < length(); i++ ) { - m_samples[i] = ( temp[i-1] + temp[i] ) * 0.5f; + m_samples[i] = ( temp[i-1] + temp[i] ) * 0.5f; } emit samplesChanged(0, length()-1); @@ -525,7 +526,7 @@ void graphModel::normalize( void ) if( max != 1.0f ) { emit samplesChanged( 0, length()-1 ); } -} +} diff --git a/src/gui/widgets/lcd_spinbox.cpp b/src/gui/widgets/lcd_spinbox.cpp index 312096d1b..537b28dbb 100644 --- a/src/gui/widgets/lcd_spinbox.cpp +++ b/src/gui/widgets/lcd_spinbox.cpp @@ -4,8 +4,8 @@ * lcd_spinbox.cpp - class lcdSpinBox, an improved QLCDNumber * * Copyright (c) 2005-2008 Tobias Doerffel - * Copyright (c) 2008 Paul Giblock - * + * Copyright (c) 2008-2009 Paul Giblock + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -118,32 +118,32 @@ void lcdSpinBox::paintEvent( QPaintEvent * _me ) int margin = 1; // QStyle::PM_DefaultFrameWidth; //int lcdWidth = m_cellWidth * m_numDigits + (margin*m_marginWidth)*2; -// p.translate( width() / 2 - lcdWidth / 2, 0 ); +// p.translate( width() / 2 - lcdWidth / 2, 0 ); p.save(); p.translate( margin, margin ); // Left Margin - p.drawPixmap( cellRect, *m_lcdPixmap, - QRect( QPoint( charsPerPixmap*m_cellWidth, - isEnabled()?0:m_cellHeight ), + p.drawPixmap( cellRect, *m_lcdPixmap, + QRect( QPoint( charsPerPixmap*m_cellWidth, + isEnabled()?0:m_cellHeight ), cellSize ) ); p.translate( m_marginWidth, 0 ); // Padding - for( int i=0; i < m_numDigits - m_display.length(); i++ ) + for( int i=0; i < m_numDigits - m_display.length(); i++ ) { - p.drawPixmap( cellRect, *m_lcdPixmap, + p.drawPixmap( cellRect, *m_lcdPixmap, QRect( QPoint( 10 * m_cellWidth, isEnabled()?0:m_cellHeight) , cellSize ) ); p.translate( m_cellWidth, 0 ); } // Digits - for( int i=0; i < m_display.length(); i++ ) + for( int i=0; i < m_display.length(); i++ ) { int val = m_display[i].digitValue(); - if( val < 0 ) + if( val < 0 ) { if( m_display[i] == '-' ) val = 11; @@ -151,14 +151,14 @@ void lcdSpinBox::paintEvent( QPaintEvent * _me ) val = 10; } p.drawPixmap( cellRect, *m_lcdPixmap, - QRect( QPoint( val*m_cellWidth, + QRect( QPoint( val*m_cellWidth, isEnabled()?0:m_cellHeight ), cellSize ) ); p.translate( m_cellWidth, 0 ); } // Right Margin - p.drawPixmap( QRect( 0, 0, m_marginWidth-1, m_cellHeight ), *m_lcdPixmap, + p.drawPixmap( QRect( 0, 0, m_marginWidth-1, m_cellHeight ), *m_lcdPixmap, QRect( charsPerPixmap*m_cellWidth, isEnabled()?0:m_cellHeight, m_cellWidth / 2, m_cellHeight ) ); @@ -184,7 +184,7 @@ void lcdSpinBox::paintEvent( QPaintEvent * _me ) p.drawText( width() / 2 - p.fontMetrics().width( m_label ) / 2 + 1, height(), m_label ); - p.setPen( QColor( 255, 255, 255 ) ); + p.setPen( palette().text().color() ); p.drawText( width() / 2 - p.fontMetrics().width( m_label ) / 2, height() - 1, m_label ); diff --git a/src/gui/widgets/led_checkbox.cpp b/src/gui/widgets/led_checkbox.cpp index c6ec082ac..494e8d9cc 100644 --- a/src/gui/widgets/led_checkbox.cpp +++ b/src/gui/widgets/led_checkbox.cpp @@ -4,7 +4,7 @@ * led_checkbox.cpp - class ledCheckBox, an improved QCheckBox * * Copyright (c) 2005-2008 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -89,7 +89,7 @@ void ledCheckBox::paintEvent( QPaintEvent * ) p.setPen( QColor( 64, 64, 64 ) ); p.drawText( m_ledOffPixmap->width() + 3, 10, text() ); - p.setPen( QColor( 255, 255, 255 ) ); + p.setPen( palette().text().color() ); p.drawText( m_ledOffPixmap->width() + 2, 9, text() ); } diff --git a/src/gui/widgets/project_notes.cpp b/src/gui/widgets/project_notes.cpp index 5ccf0b695..cf162580e 100644 --- a/src/gui/widgets/project_notes.cpp +++ b/src/gui/widgets/project_notes.cpp @@ -4,7 +4,7 @@ * project_notes.cpp - implementation of project-notes-editor * * Copyright (c) 2005-2008 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -51,9 +51,9 @@ projectNotes::projectNotes( void ) : { m_edit = new QTextEdit( this ); m_edit->setAutoFillBackground( TRUE ); - QPalette pal; - pal.setColor( m_edit->backgroundRole(), QColor( 64, 64, 64 ) ); - m_edit->setPalette( pal ); + //QPalette pal; + //pal.setColor( m_edit->backgroundRole(), QColor( 64, 64, 64 ) ); + //m_edit->setPalette( pal ); m_edit->show(); clear(); diff --git a/src/gui/widgets/text_float.cpp b/src/gui/widgets/text_float.cpp index bf68ab658..3dfc86232 100644 --- a/src/gui/widgets/text_float.cpp +++ b/src/gui/widgets/text_float.cpp @@ -4,7 +4,7 @@ * text_float.cpp - class textFloat, a floating text-label * * Copyright (c) 2005-2008 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -130,15 +130,14 @@ void textFloat::paintEvent( QPaintEvent * _pe ) { QPainter p( this ); - p.setPen( QColor( 0, 0, 0 ) ); - - p.setBrush( QColor( 224, 224, 224 ) ); + LmmsStyle * style = engine::getLmmsStyle(); + p.setPen( style->color( LmmsStyle::TextFloatForecolor ) ); + p.setBrush( style->color( LmmsStyle::TextFloatFill ) ); p.setFont( pointSize<8>( p.font() ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); -// p.setPen( Qt::black ); // small message? if( m_title == "" ) { diff --git a/src/gui/widgets/visualization_widget.cpp b/src/gui/widgets/visualization_widget.cpp index 59fe5653f..b5fc9ee96 100644 --- a/src/gui/widgets/visualization_widget.cpp +++ b/src/gui/widgets/visualization_widget.cpp @@ -4,7 +4,7 @@ * visualization_widget.cpp - widget for visualization of sound-data * * Copyright (c) 2005-2008 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -66,6 +66,7 @@ visualizationWidget::visualizationWidget( const QPixmap & _bg, QWidget * _p, visualizationWidget::~visualizationWidget() { delete[] m_buffer; + delete[] m_points; } @@ -144,20 +145,23 @@ void visualizationWidget::paintEvent( QPaintEvent * ) mixer::peakValueRight( m_buffer, frames ) ); // and set color according to that... + LmmsStyle::ColorRole levelColor; if( max_level * master_output < 0.9 ) { - p.setPen( QColor( 128, 224, 128 ) ); + levelColor = LmmsStyle::VisualizationLevelLow; } else if( max_level * master_output < 1.0 ) { - p.setPen( QColor( 255, 192, 64 ) ); + levelColor = LmmsStyle::VisualizationLevelMid; } else { - p.setPen( QColor( 255, 64, 64 ) ); + levelColor = LmmsStyle::VisualizationLevelPeak; } - p.setPen( QPen( p.pen().color(), 0.7 ) ); + p.setPen( QPen( + engine::getLmmsStyle()->color( levelColor ), + 0.7 ) ); const float xd = (float) w / frames; p.setRenderHint( QPainter::Antialiasing );