lmms
Cross-platform music production software
Toggle main menu visibility
Loading...
Searching...
No Matches
include
embed.h
Go to the documentation of this file.
1
/*
2
* embed.h - misc. stuff for using embedded data (resources linked into binary)
3
*
4
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5
*
6
* This file is part of LMMS - https://lmms.io
7
*
8
* This program is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU General Public
10
* License as published by the Free Software Foundation; either
11
* version 2 of the License, or (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public
19
* License along with this program (see COPYING); if not, write to the
20
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21
* Boston, MA 02110-1301 USA.
22
*
23
*/
24
25
#ifndef LMMS_EMBED_H
26
#define LMMS_EMBED_H
27
28
#include <string>
29
#include <string_view>
30
31
#include <QPixmap>
32
#include <QString>
33
34
#include "lmms_export.h"
35
#ifdef PLUGIN_NAME
36
#include "
LmmsCommonMacros.h
"
37
#endif
38
39
namespace
lmms
{
40
41
namespace
embed
{
42
49
auto
LMMS_EXPORT
getIconPixmap
(
50
std::string_view name,
51
int
width = -1,
52
int
height = -1,
53
const
char
*
const
* xpm =
nullptr
54
) -> QPixmap;
55
56
auto
LMMS_EXPORT
getText
(std::string_view name) -> QString;
57
61
inline
auto
logicalSize
(
const
QPixmap& pixmap)
noexcept
62
{
63
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
64
return
pixmap.deviceIndependentSize().toSize();
65
#else
66
return
pixmap.isNull() ? QSize(0, 0) : pixmap.size() / pixmap.devicePixelRatio();
67
#endif
68
}
69
70
}
// namespace embed
71
72
class
PixmapLoader
73
{
74
public
:
75
PixmapLoader
() =
default
;
76
77
explicit
PixmapLoader
(std::string name,
const
char
*
const
* xpm =
nullptr
) :
78
m_name
{std::move(name)},
79
m_xpm
{xpm}
80
{ }
81
82
virtual
~PixmapLoader
() =
default
;
83
84
auto
pixmap
(
int
width = -1,
int
height = -1) const -> QPixmap
85
{
86
return
embed::getIconPixmap
(
m_name
, width, height,
m_xpm
);
87
}
88
89
auto
pixmapName
() const -> const std::
string
& {
return
m_name
; }
90
91
private
:
92
std::string
m_name
;
93
const
char
*
const
*
m_xpm
=
nullptr
;
94
};
95
96
#ifdef PLUGIN_NAME
97
98
class
PluginPixmapLoader :
public
PixmapLoader
99
{
100
public
:
101
PluginPixmapLoader() =
default
;
102
103
explicit
PluginPixmapLoader(std::string name,
const
char
*
const
* xpm =
nullptr
) :
104
PixmapLoader
{
LMMS_STRINGIFY
(PLUGIN_NAME)
"/"
+ name, xpm}
105
{ }
106
};
107
108
namespace
PLUGIN_NAME {
109
110
inline
auto
getIconPixmap
(std::string_view name,
111
int
width = -1,
int
height = -1,
const
char
*
const
* xpm =
nullptr
) -> QPixmap
112
{
113
return
PluginPixmapLoader{std::string{name}, xpm}.pixmap(width, height);
114
}
115
116
}
// namespace PLUGIN_NAME
117
118
#endif
// PLUGIN_NAME
119
120
}
// namespace lmms
121
122
#endif
// LMMS_EMBED_H
LmmsCommonMacros.h
LMMS_STRINGIFY
#define LMMS_STRINGIFY(s)
Definition
LmmsCommonMacros.h:31
lmms::PixmapLoader
Definition
embed.h:73
lmms::PixmapLoader::m_name
std::string m_name
Definition
embed.h:92
lmms::PixmapLoader::PixmapLoader
PixmapLoader()=default
lmms::PixmapLoader::~PixmapLoader
virtual ~PixmapLoader()=default
lmms::PixmapLoader::pixmap
auto pixmap(int width=-1, int height=-1) const -> QPixmap
Definition
embed.h:84
lmms::PixmapLoader::PixmapLoader
PixmapLoader(std::string name, const char *const *xpm=nullptr)
Definition
embed.h:77
lmms::PixmapLoader::m_xpm
const char *const * m_xpm
Definition
embed.h:93
lmms::PixmapLoader::pixmapName
auto pixmapName() const -> const std::string &
Definition
embed.h:89
lmms::embed
Definition
embed.cpp:36
lmms::embed::getText
auto getText(std::string_view name) -> QString
Definition
embed.cpp:125
lmms::embed::getIconPixmap
auto getIconPixmap(std::string_view name, int width, int height, const char *const *xpm) -> QPixmap
Return an image for the icon pixmap cache.
Definition
embed.cpp:107
lmms::embed::logicalSize
auto logicalSize(const QPixmap &pixmap) noexcept
Temporary shim for QPixmap::deviceIndependentSize.
Definition
embed.h:61
lmms
Definition
RemotePluginBase.cpp:34
Generated on
for lmms by
1.18.0