Add LmmsStyle class for color and drawing hooks

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1974 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Paul Giblock
2009-01-28 07:49:08 +00:00
parent 05ff15f0e8
commit 26c20113cf
7 changed files with 505 additions and 10 deletions

76
include/classic_style.h Normal file
View File

@@ -0,0 +1,76 @@
/*
* classic_style.h - the graphical style used by LMMS for original look&feel
*
* Copyright (c) 2009 Paul Giblock <pgib/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* 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 _CLASSIC_STYLE_H
#define _CLASSIC_STYLE_H
#include <QtGui/QPlastiqueStyle>
#include "lmms_style.h"
class ClassicStyle : public QPlastiqueStyle, public LmmsStyle
{
public:
ClassicStyle();
virtual ~ClassicStyle()
{
}
// QT stuff
virtual QPalette standardPalette( void ) const;
virtual void drawComplexControl(
ComplexControl control,
const QStyleOptionComplex * option,
QPainter *painter,
const QWidget *widget ) const;
virtual void drawPrimitive( PrimitiveElement element,
const QStyleOption *option,
QPainter *painter,
const QWidget *widget = 0 ) const;
virtual int pixelMetric( PixelMetric metric,
const QStyleOption * option = 0,
const QWidget * widget = 0 ) const;
// LMMS Stuff
virtual void drawFxLine(QPainter * _painter, const QWidget *_fxLine,
const QString & _name, bool _active);
virtual void drawTrackContentBackground(QPainter * _painter,
const QSize & _size, const int _pixelsPerTact);
virtual QColor color(LmmsStyle::ColorRole _role) const;
private:
QImage colorizeXpm( const char * const * xpm, const QBrush & fill ) const;
QColor colors[LmmsStyle::NumColorRoles];
};
#endif

View File

@@ -31,6 +31,7 @@
#include <QtCore/QMap>
#include "export.h"
#include "lmms_style.h"
class automationEditor;
class bbEditor;
@@ -164,6 +165,13 @@ public:
return( s_pluginFileHandling );
}
static void setLmmsStyle( LmmsStyle * _style ) {
s_lmmsStyle = _style;
}
static LmmsStyle * getLmmsStyle( void ) {
return s_lmmsStyle;
}
private:
static bool s_hasGUI;
@@ -190,6 +198,8 @@ private:
static projectNotes * s_projectNotes;
static ladspa2LMMS * s_ladspaManager;
static LmmsStyle * s_lmmsStyle;
static QMap<QString, QString> s_pluginFileHandling;
static void initPluginFileHandling( void );

View File

@@ -2,8 +2,8 @@
* lmms_style.h - the graphical style used by LMMS to create a consistent
* interface
*
* Copyright (c) 2007-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* Copyright (c) 2009 Paul Giblock <pgib/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
@@ -27,17 +27,67 @@
#ifndef _LMMS_STYLE_H
#define _LMMS_STYLE_H
#include <QtGui/QPlastiqueStyle>
// Defines for widgets
#include "fx_mixer_view.h"
class lmmsStyle : public QPlastiqueStyle
class LmmsStyle
{
public:
lmmsStyle();
virtual ~lmmsStyle()
enum ColorRole
{
AutomationBarFill,
AutomationBarValue,
AutomationSelectedBarFill,
AutomationCrosshair,
PianoRollStepNote,
PianoRollSelectedNote,
PianoRollDefaultNote,
PianoRollEditHandle,
PianoRollVolumeLevel,
PianoRollPanningLevel,
PianoRollSelectedLevel,
TimelineForecolor,
StandardGraphLine,
StandardGraphHandle,
StandardGraphHandleBorder,
StandardGraphCrosshair,
TextFloatForecolor,
TextFloatFill,
VisualizationLevelLow,
VisualizationLevelMid,
VisualizationLevelPeak,
NumColorRoles
};
/* TODO: Still need to style:
* combobox.cpp
* fade_button.cpp
* knob.cpp - Will be reimplemented to use image-strips
* tab_widget.cpp
* tool_button.cpp - Will be obsoleted in favor of real Qt toolbars
*/
LmmsStyle()
{
}
virtual ~LmmsStyle()
{
}
virtual void drawFxLine(QPainter * _painter, const QWidget *_fxLine,
const QString & _name, bool _active) = 0;
virtual void drawTrackContentBackground(QPainter * _painter,
const QSize & _size, const int _pixelsPerTact) = 0;
virtual QColor color(ColorRole _role) const = 0;
/*
virtual QPalette standardPalette( void ) const;
virtual void drawComplexControl(
@@ -50,10 +100,22 @@ public:
QPainter *painter,
const QWidget *widget = 0 ) const;
virtual void drawControl( ControlElement element, const QStyleOption * option,
QPainter * painter, const QWidget * widget ) const;
virtual int pixelMetric( PixelMetric metric,
const QStyleOption * option = 0,
const QStyleOption * option = 0,
const QWidget * widget = 0 ) const;
QSize sizeFromContents(ContentsType type, const QStyleOption *option,
const QSize &size, const QWidget *widget) const;
QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option,
SubControl subControl, const QWidget *widget) const;
private:
QImage colorizeXpm( const char * const * xpm, const QBrush & fill ) const;
*/
} ;
#endif