-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cue colors #992
Cue colors #992
Changes from 53 commits
1aeb8b7
0d67283
b7e864d
f2d0cfa
b78cd5d
ac14bde
1065e48
c68086b
fbcc455
07997b7
ac06fc1
48eed12
168859b
9895b87
5b1dfea
a0229f7
fb939de
e977942
c1aec44
9f7230d
683638d
e4b585c
4503e06
3edd680
ae5b59e
e0bfdfd
bd49637
22b0587
67414df
4e24c09
deba2ae
1f1b107
cf6bfc4
7be5597
58405ee
30dd1bb
da6b9d9
db9b553
2f8863b
1d8ef77
74bb3bc
f3f92c2
f05d1b2
3c4f6da
360467f
09a501a
a89470c
4ef4cae
6eeea37
2859e50
030c904
7c7dea9
b682f11
6f5770f
10e5ef8
5b2fb04
fd9b4a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,25 @@ | ||
#include <QtDebug> | ||
|
||
#include "waveformmark.h" | ||
#include "skin/skincontext.h" | ||
#include "waveform/renderers/waveformmarkproperties.h" | ||
|
||
#include "waveformwidgetrenderer.h" | ||
#include "control/controlobject.h" | ||
#include "control/controlproxy.h" | ||
#include "widget/wskincolor.h" | ||
#include "waveformmark.h" | ||
|
||
WaveformMark::WaveformMark() | ||
: m_pPointCos(nullptr) { | ||
: m_iHotCue(-1) { | ||
} | ||
|
||
WaveformMark::~WaveformMark() { | ||
delete m_pPointCos; | ||
WaveformMark::WaveformMark(int hotCue) | ||
: m_iHotCue(hotCue) { | ||
} | ||
|
||
void WaveformMark::setup(const QString& group, const QDomNode& node, | ||
const SkinContext& context, | ||
const WaveformSignalColors& signalColors) { | ||
QString item = context.selectString(node, "Control"); | ||
if (!item.isEmpty()) { | ||
m_pPointCos = new ControlProxy(group, item); | ||
} | ||
|
||
m_color = context.selectString(node, "Color"); | ||
if (!m_color.isValid()) { | ||
// As a fallback, grab the color from the parent's AxesColor | ||
m_color = signalColors.getAxesColor(); | ||
qDebug() << "Didn't get mark <Color>, using parent's <AxesColor>:" << m_color; | ||
} else { | ||
m_color = WSkinColor::getCorrectColor(m_color); | ||
} | ||
|
||
m_textColor = context.selectString(node, "TextColor"); | ||
if (!m_textColor.isValid()) { | ||
// Read the text color, otherwise use the parent's BgColor. | ||
m_textColor = signalColors.getBgColor(); | ||
qDebug() << "Didn't get mark <TextColor>, using parent's <BgColor>:" << m_textColor; | ||
m_pPointCos = std::make_unique<ControlProxy>(group, item); | ||
} | ||
|
||
QString markAlign = context.selectString(node, "Align"); | ||
if (markAlign.contains("bottom", Qt::CaseInsensitive)) { | ||
m_align = Qt::AlignBottom; | ||
} else { | ||
m_align = Qt::AlignTop; // Default | ||
} | ||
|
||
m_text = context.selectString(node, "Text"); | ||
m_pixmapPath = context.selectString(node, "Pixmap"); | ||
if (!m_pixmapPath.isEmpty()) { | ||
m_pixmapPath = context.getSkinPath(m_pixmapPath); | ||
} | ||
} | ||
|
||
// called from WaveformMarkSet::setup() for hot cues | ||
// TODO(XXX): subclass and override WaveformMark::setup | ||
void WaveformMark::setKeyAndIndex(const ConfigKey& key, int i) { | ||
DEBUG_ASSERT(m_pPointCos == NULL); | ||
m_pPointCos = new ControlProxy(key); | ||
m_text = m_text.arg(i); | ||
m_properties = WaveformMarkProperties(node, context, signalColors); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,42 @@ | ||
#ifndef WAVEFORMMARK_H | ||
#define WAVEFORMMARK_H | ||
|
||
#include <QString> | ||
#include <QDomNode> | ||
#include <QImage> | ||
#include <QColor> | ||
|
||
#include "preferences/usersettings.h" | ||
#include "skin/skincontext.h" | ||
#include "control/controlproxy.h" | ||
#include "util/memory.h" | ||
|
||
class ControlProxy; | ||
class QDomNode; | ||
#include "waveform/renderers/waveformmarkproperties.h" | ||
|
||
class SkinContext; | ||
class WaveformSignalColors; | ||
|
||
class WaveformMark { | ||
public: | ||
WaveformMark(); | ||
~WaveformMark(); | ||
WaveformMark(int hotCue); | ||
|
||
void setup(const QString& group, const QDomNode& node, | ||
const SkinContext& context, | ||
const WaveformSignalColors& signalColors); | ||
void setKeyAndIndex(const ConfigKey& key, int i); | ||
|
||
private: | ||
ControlProxy* m_pPointCos; | ||
std::unique_ptr<ControlProxy> m_pPointCos; | ||
|
||
const WaveformMarkProperties& getProperties() const { return m_properties; }; | ||
void setProperties(const WaveformMarkProperties& properties) { m_properties = properties; }; | ||
|
||
QColor m_color; | ||
QColor m_textColor; | ||
QString m_text; | ||
Qt::Alignment m_align; | ||
QString m_pixmapPath; | ||
int getHotCue() const { return m_iHotCue; }; | ||
void setHotCue(int hotCue) { m_iHotCue = hotCue; }; | ||
|
||
private: | ||
WaveformMarkProperties m_properties; | ||
int m_iHotCue; | ||
QImage m_image; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the image is another intrinsic and copyable property that belongs to WaveformMarkProperties. With this modification generateMarkImage() can operate on WaveformMarkProperties directly. But I have not checked all occurrences, you may know better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this worth it? Making m_image part of WaveformMarkProperties means that in WaveformRenderMark::slotCuesUpdated we are copying it just to regenerate it afterwards. Also, it is strange to me to think about it as a "property" in the same sense than color or text. Conceptually, for me it should be a member of WaveforMark. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's ok for me. As I mentioned, I didn't take into account all the details. On 21.08.2016 15:38, Ferran Pujol Camins wrote:
|
||
|
||
friend class WaveformMarkSet; | ||
friend class WaveformRenderMark; | ||
friend class WOverview; | ||
}; | ||
|
||
typedef QSharedPointer<WaveformMark> WaveformMarkPointer; | ||
|
||
#endif // WAVEFORMMARK_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "skin/skincontext.h" | ||
#include "waveform/renderers/waveformsignalcolors.h" | ||
#include "widget/wskincolor.h" | ||
|
||
#include "waveform/renderers/waveformmarkproperties.h" | ||
|
||
WaveformMarkProperties::WaveformMarkProperties(const QDomNode& node, | ||
const SkinContext& context, | ||
const WaveformSignalColors& signalColors) { | ||
m_color = context.selectString(node, "Color"); | ||
if (!m_color.isValid()) { | ||
// As a fallback, grab the color from the parent's AxesColor | ||
m_color = signalColors.getAxesColor(); | ||
qDebug() << "Didn't get mark <Color>, using parent's <AxesColor>:" << m_color; | ||
} else { | ||
m_color = WSkinColor::getCorrectColor(m_color); | ||
} | ||
|
||
m_textColor = context.selectString(node, "TextColor"); | ||
if (!m_textColor.isValid()) { | ||
// Read the text color, otherwise use the parent's BgColor. | ||
m_textColor = signalColors.getBgColor(); | ||
qDebug() << "Didn't get mark <TextColor>, using parent's <BgColor>:" << m_textColor; | ||
} | ||
|
||
QString markAlign = context.selectString(node, "Align"); | ||
if (markAlign.contains("bottom", Qt::CaseInsensitive)) { | ||
m_align = Qt::AlignBottom; | ||
} else { | ||
m_align = Qt::AlignTop; // Default | ||
} | ||
|
||
m_text = context.selectString(node, "Text"); | ||
m_pixmapPath = context.selectString(node, "Pixmap"); | ||
if (!m_pixmapPath.isEmpty()) { | ||
m_pixmapPath = context.getSkinPath(m_pixmapPath); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef WAVEFORMMARKPROPERTIES_H | ||
#define WAVEFORMMARKPROPERTIES_H | ||
|
||
#include <QColor> | ||
#include <QDomNode> | ||
|
||
class SkinContext; | ||
class WaveformSignalColors; | ||
|
||
class WaveformMarkProperties final { | ||
public: | ||
WaveformMarkProperties() = default; | ||
WaveformMarkProperties(const QDomNode& node, | ||
const SkinContext& context, | ||
const WaveformSignalColors& signalColors); | ||
|
||
QColor m_color; | ||
QColor m_textColor; | ||
QString m_text; | ||
Qt::Alignment m_align; | ||
QString m_pixmapPath; | ||
}; | ||
|
||
#endif // WAVEFORMMARKPROPERTIES_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default constructor has become obsolete now, because C++ generates one for you. If you want to keep it for documentation purposes then use
WaveformMark() = default;
and delete the implementation. I like C++1x ;)