added slider widget
This commit is contained in:
@@ -25,8 +25,7 @@
|
||||
#include "render/rendertexture.h"
|
||||
#include "render/gl/shadergenerators.h"
|
||||
|
||||
AlphaOverBlend::AlphaOverBlend() :
|
||||
shader_(nullptr)
|
||||
AlphaOverBlend::AlphaOverBlend()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -48,7 +47,6 @@ QString AlphaOverBlend::Description()
|
||||
|
||||
void AlphaOverBlend::Release()
|
||||
{
|
||||
shader_ = nullptr;
|
||||
}
|
||||
|
||||
QVariant AlphaOverBlend::Value(NodeOutput *param, const rational &time)
|
||||
@@ -76,14 +74,8 @@ QVariant AlphaOverBlend::Value(NodeOutput *param, const rational &time)
|
||||
// Bind blend
|
||||
blend->Bind();
|
||||
|
||||
// Get default pipeline shader
|
||||
// FIXME: Come up with a good way to share pipeline shaders since a lot of nodes will just use the default
|
||||
if (shader_ == nullptr) {
|
||||
shader_ = olive::ShaderGenerator::DefaultPipeline();
|
||||
}
|
||||
|
||||
// Draw blend on base
|
||||
olive::gl::Blit(shader_);
|
||||
olive::gl::Blit(renderer->default_pipeline());
|
||||
|
||||
// Release all
|
||||
blend->Release();
|
||||
|
||||
@@ -39,7 +39,6 @@ protected:
|
||||
virtual QVariant Value(NodeOutput* param, const rational& time) override;
|
||||
|
||||
private:
|
||||
ShaderPtr shader_;
|
||||
};
|
||||
|
||||
#endif // ALPHAOVER_H
|
||||
|
||||
@@ -28,6 +28,7 @@ OpacityNode::OpacityNode()
|
||||
{
|
||||
opacity_input_ = new NodeInput("opacity_in");
|
||||
opacity_input_->add_data_input(NodeParam::kFloat);
|
||||
opacity_input_->set_value(100);
|
||||
AddParameter(opacity_input_);
|
||||
|
||||
texture_input_ = new NodeInput("tex_in");
|
||||
|
||||
@@ -88,8 +88,7 @@ void ColorService::AssociateAlphaInternal(ColorService::AlphaAction action, T *d
|
||||
for (int i=0;i<pix_count;i+=kRGBAChannels) {
|
||||
T alpha = data[i+kRGBChannels];
|
||||
|
||||
// FIXME: Is qIsNull the correct approach here or should it literally be an != 0?
|
||||
if (action == kAssociate || !qIsNull(alpha)) {
|
||||
if (action == kAssociate || alpha > 0) {
|
||||
for (int j=0;j<kRGBChannels;j++) {
|
||||
if (action == kDisassociate) {
|
||||
data[i+j] /= alpha;
|
||||
|
||||
@@ -23,6 +23,7 @@ add_subdirectory(panel)
|
||||
add_subdirectory(playbackcontrols)
|
||||
add_subdirectory(projectexplorer)
|
||||
add_subdirectory(projecttoolbar)
|
||||
add_subdirectory(slider)
|
||||
add_subdirectory(taskview)
|
||||
add_subdirectory(timelineview)
|
||||
add_subdirectory(timeruler)
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#include "node/node.h"
|
||||
#include "widget/footagecombobox/footagecombobox.h"
|
||||
#include "widget/slider/floatslider.h"
|
||||
#include "widget/slider/integerslider.h"
|
||||
|
||||
// FIXME: Test code only
|
||||
#include "panel/panelmanager.h"
|
||||
@@ -52,11 +54,19 @@ void NodeParamViewWidgetBridge::CreateWidgets()
|
||||
case NodeParam::kTrack:
|
||||
break;
|
||||
case NodeParam::kInt:
|
||||
// FIXME: LabelSlider in INTEGER mode
|
||||
{
|
||||
IntegerSlider* slider = new IntegerSlider();
|
||||
widgets_.append(slider);
|
||||
connect(slider, SIGNAL(ValueChanged(int)), this, SLOT(WidgetCallback()));
|
||||
break;
|
||||
}
|
||||
case NodeParam::kFloat:
|
||||
// FIXME: LabelSlider in FLOAT mode
|
||||
{
|
||||
FloatSlider* slider = new FloatSlider();
|
||||
widgets_.append(slider);
|
||||
connect(slider, SIGNAL(ValueChanged(double)), this, SLOT(WidgetCallback()));
|
||||
break;
|
||||
}
|
||||
case NodeParam::kFile:
|
||||
// FIXME: File selector
|
||||
break;
|
||||
@@ -67,6 +77,7 @@ void NodeParamViewWidgetBridge::CreateWidgets()
|
||||
{
|
||||
QLineEdit* line_edit = new QLineEdit();
|
||||
widgets_.append(line_edit);
|
||||
connect(line_edit, SIGNAL(textEdited(const QString &text)), this, SLOT(WidgetCallback()));
|
||||
break;
|
||||
}
|
||||
case NodeParam::kBoolean:
|
||||
@@ -116,11 +127,19 @@ void NodeParamViewWidgetBridge::WidgetCallback()
|
||||
case NodeParam::kTrack:
|
||||
break;
|
||||
case NodeParam::kInt:
|
||||
// FIXME: LabelSlider in INTEGER mode
|
||||
{
|
||||
// Widget is a IntegerSlider
|
||||
IntegerSlider* int_slider = static_cast<IntegerSlider*>(sender());
|
||||
input->set_value(int_slider->GetValue());
|
||||
break;
|
||||
}
|
||||
case NodeParam::kFloat:
|
||||
// FIXME: LabelSlider in FLOAT mode
|
||||
{
|
||||
// Widget is a FloatSlider
|
||||
FloatSlider* float_slider = static_cast<FloatSlider*>(sender());
|
||||
input->set_value(float_slider->GetValue());
|
||||
break;
|
||||
}
|
||||
case NodeParam::kFile:
|
||||
// FIXME: File selector
|
||||
break;
|
||||
@@ -130,19 +149,22 @@ void NodeParamViewWidgetBridge::WidgetCallback()
|
||||
case NodeParam::kString:
|
||||
{
|
||||
// Sender is a QLineEdit
|
||||
//QLineEdit* line_edit = static_cast<QLineEdit*>(sender());
|
||||
QLineEdit* line_edit = static_cast<QLineEdit*>(sender());
|
||||
input->set_value(line_edit->text());
|
||||
break;
|
||||
}
|
||||
case NodeParam::kBoolean:
|
||||
{
|
||||
// Widget is a QCheckBox
|
||||
//QCheckBox* check_box = static_cast<QCheckBox*>(sender());
|
||||
QCheckBox* check_box = static_cast<QCheckBox*>(sender());
|
||||
input->set_value(check_box->isChecked());
|
||||
break;
|
||||
}
|
||||
case NodeParam::kFont:
|
||||
{
|
||||
// Widget is a QFontComboBox
|
||||
//QFontComboBox* font_combobox = static_cast<QFontComboBox*>(sender());
|
||||
QFontComboBox* font_combobox = static_cast<QFontComboBox*>(sender());
|
||||
input->set_value(font_combobox->currentFont());
|
||||
break;
|
||||
}
|
||||
case NodeParam::kFootage:
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2019 Olive Team
|
||||
#
|
||||
# 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 3 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
widget/slider/floatslider.h
|
||||
widget/slider/floatslider.cpp
|
||||
widget/slider/integerslider.h
|
||||
widget/slider/integerslider.cpp
|
||||
widget/slider/sliderbase.h
|
||||
widget/slider/sliderbase.cpp
|
||||
widget/slider/sliderlabel.h
|
||||
widget/slider/sliderlabel.cpp
|
||||
widget/slider/sliderlineedit.h
|
||||
widget/slider/sliderlineedit.cpp
|
||||
widget/slider/stringslider.h
|
||||
widget/slider/stringslider.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,49 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
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 3 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "floatslider.h"
|
||||
|
||||
FloatSlider::FloatSlider(QWidget *parent) :
|
||||
SliderBase(kFloat, parent)
|
||||
{
|
||||
connect(this, SIGNAL(ValueChanged(QVariant)), this, SLOT(ConvertValue(QVariant)));
|
||||
}
|
||||
|
||||
double FloatSlider::GetValue()
|
||||
{
|
||||
return Value().toDouble();
|
||||
}
|
||||
|
||||
void FloatSlider::SetValue(const double &d)
|
||||
{
|
||||
SliderBase::SetValue(d);
|
||||
}
|
||||
|
||||
void FloatSlider::SetDecimalPlaces(int i)
|
||||
{
|
||||
decimal_places_ = i;
|
||||
|
||||
UpdateLabel(Value());
|
||||
}
|
||||
|
||||
void FloatSlider::ConvertValue(QVariant v)
|
||||
{
|
||||
emit ValueChanged(v.toDouble());
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
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 3 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef FLOATSLIDER_H
|
||||
#define FLOATSLIDER_H
|
||||
|
||||
#include "sliderbase.h"
|
||||
|
||||
class FloatSlider : public SliderBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FloatSlider(QWidget* parent = nullptr);
|
||||
|
||||
double GetValue();
|
||||
|
||||
void SetValue(const double& d);
|
||||
|
||||
void SetDecimalPlaces(int i);
|
||||
|
||||
signals:
|
||||
void ValueChanged(double);
|
||||
|
||||
private slots:
|
||||
void ConvertValue(QVariant v);
|
||||
};
|
||||
|
||||
#endif // FLOATSLIDER_H
|
||||
@@ -0,0 +1,42 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
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 3 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "integerslider.h"
|
||||
|
||||
IntegerSlider::IntegerSlider(QWidget* parent) :
|
||||
SliderBase(kInteger, parent)
|
||||
{
|
||||
connect(this, SIGNAL(ValueChanged(QVariant)), this, SLOT(ConvertValue(QVariant)));
|
||||
}
|
||||
|
||||
int IntegerSlider::GetValue()
|
||||
{
|
||||
return Value().toInt();
|
||||
}
|
||||
|
||||
void IntegerSlider::SetValue(const int &v)
|
||||
{
|
||||
SliderBase::SetValue(v);
|
||||
}
|
||||
|
||||
void IntegerSlider::ConvertValue(QVariant v)
|
||||
{
|
||||
emit ValueChanged(v.toInt());
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
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 3 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef INTEGERSLIDER_H
|
||||
#define INTEGERSLIDER_H
|
||||
|
||||
#include "sliderbase.h"
|
||||
|
||||
class IntegerSlider : public SliderBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
IntegerSlider(QWidget* parent = nullptr);
|
||||
|
||||
int GetValue();
|
||||
|
||||
void SetValue(const int& v);
|
||||
|
||||
signals:
|
||||
void ValueChanged(int);
|
||||
|
||||
private slots:
|
||||
void ConvertValue(QVariant v);
|
||||
};
|
||||
|
||||
#endif // INTEGERSLIDER_H
|
||||
@@ -0,0 +1,233 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
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 3 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "sliderbase.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QMessageBox>
|
||||
|
||||
SliderBase::SliderBase(Mode mode, QWidget *parent) :
|
||||
QStackedWidget(parent),
|
||||
decimal_places_(1),
|
||||
drag_multiplier_(1.0),
|
||||
mode_(mode),
|
||||
dragged_(false)
|
||||
{
|
||||
label_ = new SliderLabel(this);
|
||||
addWidget(label_);
|
||||
|
||||
editor_ = new SliderLineEdit(this);
|
||||
addWidget(editor_);
|
||||
|
||||
connect(label_, SIGNAL(drag_start()), this, SLOT(LabelPressed()));
|
||||
connect(label_, SIGNAL(dragged(int)), this, SLOT(LabelDragged(int)));
|
||||
connect(label_, SIGNAL(drag_stop()), this, SLOT(LabelClicked()));
|
||||
connect(editor_, SIGNAL(Confirmed()), this, SLOT(LineEditConfirmed()));
|
||||
connect(editor_, SIGNAL(Cancelled()), this, SLOT(LineEditCancelled()));
|
||||
|
||||
// Set valid cursor based on mode
|
||||
switch (mode_) {
|
||||
case kString:
|
||||
setCursor(Qt::PointingHandCursor);
|
||||
value_ = "";
|
||||
break;
|
||||
case kInteger:
|
||||
case kFloat:
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
value_ = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateLabel(value_);
|
||||
}
|
||||
|
||||
void SliderBase::SetDragMultiplier(const double &d)
|
||||
{
|
||||
drag_multiplier_ = d;
|
||||
}
|
||||
|
||||
const QVariant &SliderBase::Value()
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
void SliderBase::SetValue(const QVariant &v)
|
||||
{
|
||||
value_ = v;
|
||||
|
||||
UpdateLabel(value_);
|
||||
}
|
||||
|
||||
void SliderBase::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
UpdateLabel(value_);
|
||||
}
|
||||
QStackedWidget::changeEvent(e);
|
||||
}
|
||||
|
||||
void SliderBase::UpdateLabel(const QVariant &v)
|
||||
{
|
||||
switch (mode_) {
|
||||
case kString:
|
||||
{
|
||||
QString vstr = v.toString();
|
||||
|
||||
if (vstr.isEmpty()) {
|
||||
label_->setText(tr("(none)"));
|
||||
} else {
|
||||
label_->setText(vstr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kInteger:
|
||||
label_->setText(v.toString());
|
||||
break;
|
||||
case kFloat:
|
||||
// For floats, we show a limited number of decimal places
|
||||
label_->setText(QString::number(v.toDouble(), 'f', decimal_places_));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SliderBase::LabelPressed()
|
||||
{
|
||||
dragged_ = false;
|
||||
|
||||
if (mode_ != kString) {
|
||||
temp_drag_value_ = value_.toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
void SliderBase::LabelClicked()
|
||||
{
|
||||
if (dragged_) {
|
||||
// This was a drag
|
||||
switch (mode_) {
|
||||
case kString:
|
||||
// No-op
|
||||
break;
|
||||
case kInteger:
|
||||
value_ = qRound(temp_drag_value_);
|
||||
break;
|
||||
case kFloat:
|
||||
value_ = temp_drag_value_;
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateLabel(value_);
|
||||
} else {
|
||||
// This was a simple click
|
||||
|
||||
// Load label's text into editor
|
||||
editor_->setText(label_->text());
|
||||
|
||||
// Show editor
|
||||
setCurrentWidget(editor_);
|
||||
|
||||
// Select all text in the editor
|
||||
editor_->setFocus();
|
||||
editor_->selectAll();
|
||||
}
|
||||
}
|
||||
|
||||
void SliderBase::LabelDragged(int i)
|
||||
{
|
||||
switch (mode_) {
|
||||
case kString:
|
||||
// No dragging supported for strings
|
||||
break;
|
||||
case kInteger:
|
||||
case kFloat:
|
||||
{
|
||||
double real_drag = static_cast<double>(i) * drag_multiplier_;
|
||||
|
||||
temp_drag_value_ += real_drag;
|
||||
|
||||
if (mode_ == kInteger) {
|
||||
UpdateLabel(qRound(temp_drag_value_));
|
||||
} else {
|
||||
UpdateLabel(temp_drag_value_);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dragged_ = true;
|
||||
}
|
||||
|
||||
void SliderBase::LineEditConfirmed()
|
||||
{
|
||||
bool is_valid = true;
|
||||
QVariant test_val;
|
||||
|
||||
// Check whether the entered value is valid for this mode
|
||||
switch (mode_) {
|
||||
case kString:
|
||||
// Anything goes for a string
|
||||
test_val = editor_->text();
|
||||
break;
|
||||
case kInteger:
|
||||
case kFloat:
|
||||
// Allow both floats and integers for either modes
|
||||
test_val = editor_->text().toDouble(&is_valid);
|
||||
|
||||
if (is_valid && mode_ == kInteger) {
|
||||
// But for an integer, we round it
|
||||
test_val = qRound(test_val.toDouble());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_valid) {
|
||||
value_ = test_val;
|
||||
|
||||
UpdateLabel(value_);
|
||||
|
||||
emit ValueChanged(value_);
|
||||
|
||||
setCurrentWidget(label_);
|
||||
} else {
|
||||
// Ensure the editor focusing out when the messagebox appears does not cause another messagebox
|
||||
editor_->blockSignals(true);
|
||||
|
||||
QMessageBox::critical(this,
|
||||
tr("Invalid Value"),
|
||||
tr("The entered value is not valid for this field."),
|
||||
QMessageBox::Ok);
|
||||
|
||||
// Refocus editor
|
||||
editor_->setFocus();
|
||||
|
||||
editor_->blockSignals(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SliderBase::LineEditCancelled()
|
||||
{
|
||||
// Ensure editor doesn't signal that the focus is lost
|
||||
editor_->blockSignals(true);
|
||||
|
||||
// Set widget back to label
|
||||
setCurrentWidget(label_);
|
||||
|
||||
editor_->blockSignals(false);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
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 3 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SLIDERBASE_H
|
||||
#define SLIDERBASE_H
|
||||
|
||||
#include <QStackedWidget>
|
||||
|
||||
#include "sliderlabel.h"
|
||||
#include "sliderlineedit.h"
|
||||
|
||||
class SliderBase : public QStackedWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Mode {
|
||||
kString,
|
||||
kInteger,
|
||||
kFloat
|
||||
};
|
||||
|
||||
SliderBase(Mode mode, QWidget* parent = nullptr);
|
||||
|
||||
void SetDragMultiplier(const double& d);
|
||||
|
||||
signals:
|
||||
void ValueChanged(QVariant v);
|
||||
|
||||
protected:
|
||||
const QVariant& Value();
|
||||
|
||||
void SetValue(const QVariant& v);
|
||||
|
||||
void UpdateLabel(const QVariant& v);
|
||||
|
||||
virtual void changeEvent(QEvent* e) override;
|
||||
|
||||
int decimal_places_;
|
||||
|
||||
double drag_multiplier_;
|
||||
|
||||
private:
|
||||
SliderLabel* label_;
|
||||
|
||||
SliderLineEdit* editor_;
|
||||
|
||||
QVariant value_;
|
||||
|
||||
Mode mode_;
|
||||
|
||||
bool dragged_;
|
||||
|
||||
double temp_drag_value_;
|
||||
|
||||
private slots:
|
||||
void LabelPressed();
|
||||
|
||||
void LabelClicked();
|
||||
|
||||
void LabelDragged(int i);
|
||||
|
||||
void LineEditConfirmed();
|
||||
|
||||
void LineEditCancelled();
|
||||
};
|
||||
|
||||
#endif // SLIDERBASE_H
|
||||
@@ -0,0 +1,72 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
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 3 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "sliderlabel.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMouseEvent>
|
||||
|
||||
SliderLabel::SliderLabel(QWidget *parent) :
|
||||
QLabel(parent)
|
||||
{
|
||||
// Use highlight color as font color
|
||||
setForegroundRole(QPalette::Highlight);
|
||||
|
||||
// Set underlined
|
||||
QFont f = font();
|
||||
f.setUnderline(true);
|
||||
setFont(f);
|
||||
}
|
||||
|
||||
void SliderLabel::mousePressEvent(QMouseEvent *ev)
|
||||
{
|
||||
QLabel::mousePressEvent(ev);
|
||||
|
||||
drag_start_ = QCursor::pos();
|
||||
|
||||
static_cast<QGuiApplication*>(QApplication::instance())->setOverrideCursor(Qt::BlankCursor);
|
||||
|
||||
emit drag_start();
|
||||
}
|
||||
|
||||
void SliderLabel::mouseMoveEvent(QMouseEvent *ev)
|
||||
{
|
||||
QLabel::mouseMoveEvent(ev);
|
||||
|
||||
QPoint current_pos = QCursor::pos();
|
||||
|
||||
int x_mvmt = current_pos.x() - drag_start_.x();
|
||||
int y_mvmt = drag_start_.y() - current_pos.y();
|
||||
|
||||
emit dragged(x_mvmt + y_mvmt);
|
||||
|
||||
// Keep cursor in the same position
|
||||
QCursor::setPos(drag_start_);
|
||||
}
|
||||
|
||||
void SliderLabel::mouseReleaseEvent(QMouseEvent *ev)
|
||||
{
|
||||
QWidget::mouseReleaseEvent(ev);
|
||||
|
||||
// Emit a clicked signal
|
||||
emit drag_stop();
|
||||
|
||||
static_cast<QGuiApplication*>(QApplication::instance())->restoreOverrideCursor();
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
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 3 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SLIDERLABEL_H
|
||||
#define SLIDERLABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
class SliderLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SliderLabel(QWidget* parent);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *ev) override;
|
||||
|
||||
void mouseMoveEvent(QMouseEvent *ev) override;
|
||||
|
||||
void mouseReleaseEvent(QMouseEvent *ev) override;
|
||||
|
||||
signals:
|
||||
void dragged(int x);
|
||||
|
||||
void drag_start();
|
||||
|
||||
void drag_stop();
|
||||
|
||||
private:
|
||||
QPoint drag_start_;
|
||||
|
||||
};
|
||||
|
||||
#endif // SLIDERLABEL_H
|
||||
@@ -0,0 +1,51 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
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 3 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "sliderlineedit.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
SliderLineEdit::SliderLineEdit(QWidget *parent) :
|
||||
QLineEdit(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SliderLineEdit::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
switch (e->key()) {
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
emit Confirmed();
|
||||
break;
|
||||
case Qt::Key_Escape:
|
||||
emit Cancelled();
|
||||
break;
|
||||
default:
|
||||
QLineEdit::keyPressEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
void SliderLineEdit::focusOutEvent(QFocusEvent *e)
|
||||
{
|
||||
QLineEdit::focusOutEvent(e);
|
||||
|
||||
emit Confirmed();
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
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 3 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SLIDERLINEEDIT_H
|
||||
#define SLIDERLINEEDIT_H
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
class SliderLineEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SliderLineEdit(QWidget* parent);
|
||||
|
||||
signals:
|
||||
void Confirmed();
|
||||
|
||||
void Cancelled();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *) override;
|
||||
|
||||
void focusOutEvent(QFocusEvent *) override;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // SLIDERLINEEDIT_H
|
||||
@@ -0,0 +1,42 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
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 3 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "stringslider.h"
|
||||
|
||||
StringSlider::StringSlider(QWidget* parent) :
|
||||
SliderBase(kString, parent)
|
||||
{
|
||||
connect(this, SIGNAL(ValueChanged(QVariant)), this, SLOT(ConvertValue(QVariant)));
|
||||
}
|
||||
|
||||
QString StringSlider::GetValue()
|
||||
{
|
||||
return Value().toString();
|
||||
}
|
||||
|
||||
void StringSlider::SetValue(const QString &v)
|
||||
{
|
||||
SliderBase::SetValue(v);
|
||||
}
|
||||
|
||||
void StringSlider::ConvertValue(QVariant v)
|
||||
{
|
||||
emit ValueChanged(v.toString());
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
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 3 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef STRINGSLIDER_H
|
||||
#define STRINGSLIDER_H
|
||||
|
||||
#include "sliderbase.h"
|
||||
|
||||
class StringSlider : public SliderBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
StringSlider(QWidget* parent = nullptr);
|
||||
|
||||
void SetDragMultiplier(const double& d) = delete;
|
||||
|
||||
QString GetValue();
|
||||
|
||||
void SetValue(const QString& v);
|
||||
|
||||
signals:
|
||||
void ValueChanged(QString);
|
||||
|
||||
private slots:
|
||||
void ConvertValue(QVariant v);
|
||||
};
|
||||
|
||||
#endif // STRINGSLIDER_H
|
||||
Reference in New Issue
Block a user