Files
lmms/include/embed.h
Johannes Lorenz 7db3fa94a1 Improve includes (#6320)
* Update ringbuffer submodule to fix includes

* Remove cyclic includes

* Remove Qt include prefixes

* Include C++ versions of C headers

E.g.: assert.h -> cassert

* Move CLIP_BORDER_WIDTH into ClipView

This allows to remove includes to TrackView.h in ClipView cpp files.

* Elliminate useless includes

This improves the include structure by elliminating includes that are
not used. Most of this was done by using `include-what-you-use` with
`CMAKE_C_INCLUDE_WHAT_YOU_USE` and `CMAKE_CXX_INCLUDE_WHAT_YOU_USE`
set to (broken down here):

```
include-what-you-use;
    -Xiwyu;--mapping_file=/usr/share/include-what-you-use/qt5_11.imp;
    -Xiwyu;--keep=*/xmmintrin.h;
    -Xiwyu;--keep=*/lmmsconfig.h;
    -Xiwyu;--keep=*/weak_libjack.h;
    -Xiwyu;--keep=*/sys/*;
    -Xiwyu;--keep=*/debug.h;
    -Xiwyu;--keep=*/SDL/*;
    -Xiwyu;--keep=*/alsa/*;
    -Xiwyu;--keep=*/FL/x.h;
    -Xiwyu;--keep=*/MidiApple.h;
    -Xiwyu;--keep=*/MidiWinMM.h;
    -Xiwyu;--keep=*/AudioSoundIo.h
```

* Fixup: Remove empty #if-#ifdef pairs

* Remove LMMS_HAVE_STD(LIB|INT)_H
2022-03-02 13:30:43 +01:00

141 lines
3.0 KiB
C++

/*
* embed.h - misc. stuff for using embedded data (resources linked into binary)
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* 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 EMBED_H
#define EMBED_H
#include <QPixmap>
#include <QString>
#include "lmms_export.h"
#include "lmms_basics.h"
namespace embed
{
/**
* Return an image for the icon pixmap cache.
*
* @param _name Identifier for the pixmap. If it is not in the icon pixmap
* cache, it will be loaded from the artwork QDir search paths (exceptions are
* compiled-in XPMs, you need to provide @p xpm for loading them).
* @param xpm Must be XPM data if the source should be raw XPM data instead of
* a file
*/
QPixmap LMMS_EXPORT getIconPixmap( const QString& _name,
int _w = -1, int _h = -1 , const char** xpm = nullptr );
QString LMMS_EXPORT getText( const char * _name );
}
#ifdef PLUGIN_NAME
namespace PLUGIN_NAME
{
inline QPixmap getIconPixmap( const QString& _name,
int _w = -1, int _h = -1, const char** xpm = nullptr )
{
return embed::getIconPixmap(QString("%1/%2").arg(STRINGIFY(PLUGIN_NAME), _name), _w, _h, xpm);
}
//QString getText( const char * _name );
}
#endif
class PixmapLoader
{
public:
PixmapLoader( const PixmapLoader * _ref ) :
m_name( _ref != nullptr ? _ref->m_name : QString() ),
m_xpm( _ref->m_xpm )
{
}
PixmapLoader( const QString & _name = QString(),
const char** xpm = nullptr ) :
m_name( _name ),
m_xpm(xpm)
{
}
virtual QPixmap pixmap() const
{
if( !m_name.isEmpty() )
{
return( embed::getIconPixmap(
m_name.toLatin1().constData(), -1, -1, m_xpm ));
}
return( QPixmap() );
}
virtual ~PixmapLoader()
{
}
virtual QString pixmapName() const
{
return m_name;
}
protected:
QString m_name;
const char** m_xpm = nullptr;
} ;
#ifdef PLUGIN_NAME
class PluginPixmapLoader : public PixmapLoader
{
public:
PluginPixmapLoader( const QString & _name = QString() ) :
PixmapLoader( _name )
{
}
virtual QPixmap pixmap() const
{
if( !m_name.isEmpty() )
{
return( PLUGIN_NAME::getIconPixmap(
m_name.toLatin1().constData() ) );
}
return( QPixmap() );
}
virtual QString pixmapName() const
{
return QString( STRINGIFY(PLUGIN_NAME) ) + "::" + m_name;
}
} ;
#endif
#endif