Implement Alt Click to default on sliders
The following sliders now have Alt Click functionality:
- Nodes (What it's initialy set too or 0 if not)
- Export Dialog Dimensions~ (Defaults to Sequence width/height)
- Export Compression Settings~
- Advanced (0)
- Speed/Duration
- Speed (100%)
- Duration (clip length)
- Stream Properties Image sequence
- Start Index (1)
- End Index (sequence length)
Sliders with no default value set ignore an Alt
Click.
Added SliderBase::SetDefaultValue() which sets the
default value of a slider.
Added ValueReset() to SliderBase signals which is
called if a slider is Alt Clicked on. Only updates
if default_value_ is not Null.
This commit is contained in:
@@ -66,6 +66,7 @@ const QList<QWidget *> &NodeParamViewWidgetBridge::widgets() const
|
||||
|
||||
void NodeParamViewWidgetBridge::CreateWidgets()
|
||||
{
|
||||
|
||||
if (input_->IsArray()) {
|
||||
|
||||
NodeParamViewArrayWidget* w = new NodeParamViewArrayWidget(static_cast<NodeInputArray*>(input_));
|
||||
@@ -91,6 +92,11 @@ void NodeParamViewWidgetBridge::CreateWidgets()
|
||||
case NodeParam::kInt:
|
||||
{
|
||||
IntegerSlider* slider = new IntegerSlider();
|
||||
if (!input_->get_standard_value().isNull()) {
|
||||
slider->SetDefaultValue(input_->get_standard_value());
|
||||
} else {
|
||||
slider->SetDefaultValue(0);
|
||||
}
|
||||
widgets_.append(slider);
|
||||
connect(slider, &IntegerSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
||||
break;
|
||||
@@ -363,6 +369,11 @@ void NodeParamViewWidgetBridge::CreateSliders(int count)
|
||||
{
|
||||
for (int i=0;i<count;i++) {
|
||||
FloatSlider* fs = new FloatSlider();
|
||||
if (!input_->get_standard_value().isNull()) {
|
||||
fs->SetDefaultValue(input_->get_split_standard_value().at(i));
|
||||
} else {
|
||||
fs->SetDefaultValue(0.0f);
|
||||
}
|
||||
widgets_.append(fs);
|
||||
connect(fs, &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QGuiApplication>
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
@@ -49,6 +50,7 @@ SliderBase::SliderBase(Mode mode, QWidget *parent) :
|
||||
connect(label_, SIGNAL(dragged(int)), this, SLOT(LabelDragged(int)));
|
||||
connect(label_, SIGNAL(drag_stop()), this, SLOT(LabelClicked()));
|
||||
connect(label_, SIGNAL(focused()), this, SLOT(LabelClicked()));
|
||||
connect(label_, SIGNAL(ResetResult()), this, SLOT(ValueReset()));
|
||||
connect(editor_, SIGNAL(Confirmed()), this, SLOT(LineEditConfirmed()));
|
||||
connect(editor_, SIGNAL(Cancelled()), this, SLOT(LineEditCancelled()));
|
||||
|
||||
@@ -137,6 +139,11 @@ void SliderBase::SetValue(const QVariant &v)
|
||||
UpdateLabel(value_);
|
||||
}
|
||||
|
||||
void SliderBase::SetDefaultValue(const QVariant &v)
|
||||
{
|
||||
default_value_ = ClampValue(v);
|
||||
}
|
||||
|
||||
void SliderBase::SetMinimumInternal(const QVariant &v)
|
||||
{
|
||||
min_value_ = v;
|
||||
@@ -241,7 +248,6 @@ void SliderBase::LabelClicked()
|
||||
emit ValueChanged(value_);
|
||||
} else {
|
||||
// This was a simple click
|
||||
|
||||
// Load label's text into editor
|
||||
editor_->setText(ValueToString(value_));
|
||||
|
||||
@@ -327,4 +333,12 @@ void SliderBase::LineEditCancelled()
|
||||
label_->blockSignals(false);
|
||||
}
|
||||
|
||||
void SliderBase::ValueReset()
|
||||
{
|
||||
if (!default_value_.isNull()) {
|
||||
SetValue(default_value_);
|
||||
emit ValueChanged(value_);
|
||||
}
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -45,6 +45,8 @@ public:
|
||||
|
||||
void SetAlignment(Qt::Alignment alignment);
|
||||
|
||||
void SetDefaultValue(const QVariant& v);
|
||||
|
||||
bool IsTristate() const;
|
||||
void SetTristate();
|
||||
|
||||
@@ -89,6 +91,7 @@ private:
|
||||
FocusableLineEdit* editor_;
|
||||
|
||||
QVariant value_;
|
||||
QVariant default_value_;
|
||||
|
||||
bool has_min_;
|
||||
QVariant min_value_;
|
||||
@@ -120,6 +123,8 @@ private slots:
|
||||
void LineEditConfirmed();
|
||||
|
||||
void LineEditCancelled();
|
||||
|
||||
void ValueReset();
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -55,49 +55,60 @@ SliderLabel::SliderLabel(QWidget *parent) :
|
||||
|
||||
void SliderLabel::mousePressEvent(QMouseEvent *)
|
||||
{
|
||||
emit drag_start();
|
||||
if (QGuiApplication::keyboardModifiers().testFlag(Qt::AltModifier)) {
|
||||
emit ResetResult();
|
||||
}else {
|
||||
emit drag_start();
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
CGAssociateMouseAndMouseCursorPosition(false);
|
||||
CGDisplayHideCursor(kCGDirectMainDisplay);
|
||||
CGGetLastMouseDelta(nullptr, nullptr);
|
||||
CGAssociateMouseAndMouseCursorPosition(false);
|
||||
CGDisplayHideCursor(kCGDirectMainDisplay);
|
||||
CGGetLastMouseDelta(nullptr, nullptr);
|
||||
#else
|
||||
drag_start_ = QCursor::pos();
|
||||
drag_start_ = QCursor::pos();
|
||||
|
||||
static_cast<QGuiApplication*>(QApplication::instance())->setOverrideCursor(Qt::BlankCursor);
|
||||
static_cast<QGuiApplication*>(QApplication::instance())->setOverrideCursor(Qt::BlankCursor);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void SliderLabel::mouseMoveEvent(QMouseEvent *)
|
||||
{
|
||||
int32_t x_mvmt, y_mvmt;
|
||||
if (QGuiApplication::keyboardModifiers().testFlag(Qt::AltModifier)) {
|
||||
// do nothing
|
||||
}else {
|
||||
int32_t x_mvmt, y_mvmt;
|
||||
|
||||
// Keep cursor in the same position
|
||||
// Keep cursor in the same position
|
||||
#if defined(Q_OS_MAC)
|
||||
CGGetLastMouseDelta(&x_mvmt, &y_mvmt);
|
||||
CGGetLastMouseDelta(&x_mvmt, &y_mvmt);
|
||||
#else
|
||||
QPoint current_pos = QCursor::pos();
|
||||
QPoint current_pos = QCursor::pos();
|
||||
|
||||
x_mvmt = current_pos.x() - drag_start_.x();
|
||||
y_mvmt = drag_start_.y() - current_pos.y();
|
||||
x_mvmt = current_pos.x() - drag_start_.x();
|
||||
y_mvmt = drag_start_.y() - current_pos.y();
|
||||
|
||||
QCursor::setPos(drag_start_);
|
||||
QCursor::setPos(drag_start_);
|
||||
#endif
|
||||
|
||||
emit dragged(x_mvmt + y_mvmt);
|
||||
emit dragged(x_mvmt + y_mvmt);
|
||||
}
|
||||
}
|
||||
|
||||
void SliderLabel::mouseReleaseEvent(QMouseEvent *)
|
||||
{
|
||||
if (QGuiApplication::keyboardModifiers().testFlag(Qt::AltModifier)) {
|
||||
//do nothing
|
||||
} else {
|
||||
// Emit a clicked signal
|
||||
emit drag_stop();
|
||||
}
|
||||
#if defined(Q_OS_MAC)
|
||||
CGAssociateMouseAndMouseCursorPosition(true);
|
||||
CGDisplayShowCursor(kCGDirectMainDisplay);
|
||||
#else
|
||||
static_cast<QGuiApplication*>(QApplication::instance())->restoreOverrideCursor();
|
||||
#endif
|
||||
|
||||
// Emit a clicked signal
|
||||
emit drag_stop();
|
||||
}
|
||||
|
||||
void SliderLabel::focusInEvent(QFocusEvent *event)
|
||||
|
||||
@@ -51,6 +51,8 @@ signals:
|
||||
|
||||
void focused();
|
||||
|
||||
void ResetResult();
|
||||
|
||||
private:
|
||||
QPoint drag_start_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user