improved effects signalling
This commit is contained in:
+10
-11
@@ -37,14 +37,13 @@ void AudioMonitor::resizeEvent(QResizeEvent *e) {
|
||||
|
||||
void AudioMonitor::paintEvent(QPaintEvent *) {
|
||||
if (sequence != NULL) {
|
||||
|
||||
QPainter p(this);
|
||||
int channel_x = AUDIO_MONITOR_GAP;
|
||||
int channel_count = av_get_channel_layout_nb_channels(sequence->audio_layout);
|
||||
if (peaks.size() != channel_count) {
|
||||
/*if (peaks.size() != channel_count) {
|
||||
peaks.resize(channel_count);
|
||||
peaks.fill(false);
|
||||
}
|
||||
}*/
|
||||
int channel_width = (width()/channel_count) - AUDIO_MONITOR_GAP;
|
||||
long playhead_offset = -1;
|
||||
int i;
|
||||
@@ -52,25 +51,25 @@ void AudioMonitor::paintEvent(QPaintEvent *) {
|
||||
QRect r(channel_x, AUDIO_MONITOR_PEAK_HEIGHT + AUDIO_MONITOR_GAP, channel_width, height());
|
||||
p.fillRect(r, gradient);
|
||||
|
||||
if (sample_cache_offset != -1) {
|
||||
if (sample_cache_offset != -1 && sample_cache.size() > 0) {
|
||||
playhead_offset = (panel_timeline->playhead - sample_cache_offset) * channel_count;
|
||||
if (playhead_offset >= 0 && playhead_offset < sample_cache.size()) {
|
||||
double multiplier = 1 - qAbs((double) sample_cache.at(playhead_offset+i) / 32768.0); // 16-bit int divided to float
|
||||
if (multiplier == (double) 0) {
|
||||
if (playhead_offset >= 0 && playhead_offset < sample_cache.size()) {
|
||||
double multiplier = 1 - qAbs((double) sample_cache.at(playhead_offset+i) / 32768.0); // 16-bit int divided to float
|
||||
/*if (multiplier == (double) 0) {
|
||||
peaks[i] = true;
|
||||
}
|
||||
}*/
|
||||
r.setHeight(r.height()*multiplier);
|
||||
} else {
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
QRect peak_rect(channel_x, 0, channel_width, AUDIO_MONITOR_PEAK_HEIGHT);
|
||||
if (peaks.at(i)) {
|
||||
/*QRect peak_rect(channel_x, 0, channel_width, AUDIO_MONITOR_PEAK_HEIGHT);
|
||||
if (peaks.at(i)) {
|
||||
p.fillRect(peak_rect, QColor(255, 0, 0));
|
||||
} else {
|
||||
p.fillRect(peak_rect, QColor(64, 0, 0));
|
||||
}
|
||||
}*/
|
||||
|
||||
p.fillRect(r, QColor(0, 0, 0, 160));
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public slots:
|
||||
|
||||
private:
|
||||
QLinearGradient gradient;
|
||||
QVector<bool> peaks;
|
||||
// QVector<bool> peaks;
|
||||
};
|
||||
|
||||
#endif // AUDIOMONITOR_H
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "checkboxex.h"
|
||||
|
||||
#include "project/undo.h"
|
||||
|
||||
CheckboxEx::CheckboxEx(QWidget* parent) : QCheckBox(parent) {
|
||||
connect(this, SIGNAL(clicked(bool)), this, SLOT(checkbox_command()));
|
||||
}
|
||||
|
||||
void CheckboxEx::checkbox_command() {
|
||||
CheckboxCommand* c = new CheckboxCommand(this);
|
||||
undo_stack.push(c);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef CHECKBOXEX_H
|
||||
#define CHECKBOXEX_H
|
||||
|
||||
#include <QCheckBox>
|
||||
|
||||
class CheckboxEx : public QCheckBox
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CheckboxEx(QWidget* parent = 0);
|
||||
private slots:
|
||||
void checkbox_command();
|
||||
};
|
||||
|
||||
#endif // CHECKBOXEX_H
|
||||
@@ -1,8 +1,9 @@
|
||||
#include "collapsiblewidget.h"
|
||||
|
||||
#include "ui/checkboxex.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLabel>
|
||||
#include <QCheckBox>
|
||||
#include <QLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
@@ -24,7 +25,7 @@ CollapsibleWidget::CollapsibleWidget(QWidget* parent) : QWidget(parent) {
|
||||
QHBoxLayout* title_bar_layout = new QHBoxLayout();
|
||||
title_bar_layout->setMargin(5);
|
||||
title_bar->setLayout(title_bar_layout);
|
||||
enabled_check = new QCheckBox();
|
||||
enabled_check = new CheckboxEx();
|
||||
enabled_check->setChecked(true);
|
||||
header = new QLabel();
|
||||
collapse_button = new QPushButton("[-]");
|
||||
|
||||
@@ -8,6 +8,7 @@ class QHBoxLayout;
|
||||
class QVBoxLayout;
|
||||
class QPushButton;
|
||||
class QFrame;
|
||||
class CheckboxEx;
|
||||
|
||||
class CollapsibleWidgetHeader : public QWidget {
|
||||
Q_OBJECT
|
||||
@@ -30,7 +31,7 @@ public:
|
||||
void setText(const QString &);
|
||||
bool is_focused();
|
||||
|
||||
QCheckBox* enabled_check;
|
||||
CheckboxEx* enabled_check;
|
||||
bool selected;
|
||||
private:
|
||||
QLabel* header;
|
||||
|
||||
+2
-1
@@ -23,7 +23,6 @@ void ColorButton::set_button_color() {
|
||||
QPalette pal = palette();
|
||||
pal.setColor(QPalette::Button, color);
|
||||
setPalette(pal);
|
||||
emit color_changed();
|
||||
}
|
||||
|
||||
void ColorButton::open_dialog() {
|
||||
@@ -34,6 +33,8 @@ void ColorButton::open_dialog() {
|
||||
undo_stack.push(command);
|
||||
|
||||
set_button_color();
|
||||
|
||||
emit color_changed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -14,11 +14,11 @@ LabelSlider::LabelSlider(QWidget* parent) : QLabel(parent) {
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
internal_value = -1;
|
||||
set_default_value(0);
|
||||
set_value(0);
|
||||
set_value(0, false);
|
||||
set = false;
|
||||
}
|
||||
|
||||
void LabelSlider::set_value(double v) {
|
||||
void LabelSlider::set_value(double v, bool userSet) {
|
||||
set = true;
|
||||
if (v != internal_value) {
|
||||
if (min_enabled && v < min_value) {
|
||||
@@ -30,7 +30,7 @@ void LabelSlider::set_value(double v) {
|
||||
}
|
||||
|
||||
setText(QString::number(internal_value));
|
||||
emit valueChanged();
|
||||
if (userSet) emit valueChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ double LabelSlider::value() {
|
||||
void LabelSlider::set_default_value(double v) {
|
||||
default_value = v;
|
||||
if (!set) {
|
||||
set_value(v);
|
||||
set_value(v, false);
|
||||
set = false;
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ void LabelSlider::mousePressEvent(QMouseEvent *ev) {
|
||||
vcc->new_val = default_value;
|
||||
undo_stack.push(vcc);
|
||||
|
||||
set_value(default_value);
|
||||
set_value(default_value, true);
|
||||
} else {
|
||||
qApp->setOverrideCursor(Qt::BlankCursor);
|
||||
drag_start_value = internal_value;
|
||||
@@ -80,7 +80,7 @@ void LabelSlider::mousePressEvent(QMouseEvent *ev) {
|
||||
|
||||
void LabelSlider::mouseMoveEvent(QMouseEvent*) {
|
||||
if (drag_start) {
|
||||
set_value(internal_value + (cursor().pos().x()-drag_start_x) + (drag_start_y-cursor().pos().y()));
|
||||
set_value(internal_value + (cursor().pos().x()-drag_start_x) + (drag_start_y-cursor().pos().y()), true);
|
||||
cursor().setPos(drag_start_x, drag_start_y);
|
||||
drag_proc = true;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ void LabelSlider::mouseReleaseEvent(QMouseEvent*) {
|
||||
vcc->source = this;
|
||||
vcc->old_val = internal_value;
|
||||
|
||||
set_value(d);
|
||||
set_value(d, true);
|
||||
|
||||
vcc->new_val = internal_value;
|
||||
undo_stack.push(vcc);
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ class LabelSlider : public QLabel
|
||||
Q_OBJECT
|
||||
public:
|
||||
LabelSlider(QWidget* parent = 0);
|
||||
void set_value(double v);
|
||||
void set_value(double v, bool userSet);
|
||||
void set_default_value(double v);
|
||||
void set_minimum_value(double v);
|
||||
void set_maximum_value(double v);
|
||||
|
||||
Reference in New Issue
Block a user