style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
@@ -33,14 +33,14 @@ DecimalSliderBase::DecimalSliderBase(QWidget *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void DecimalSliderBase::SetAutoTrimDecimalPlaces(bool e)
|
||||
void DecimalSliderBase::set_auto_trim_decimal_places(bool e)
|
||||
{
|
||||
autotrim_decimal_places_ = e;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
QString DecimalSliderBase::FloatToString(double val, int decimal_places,
|
||||
QString DecimalSliderBase::float_to_string(double val, int decimal_places,
|
||||
bool autotrim_decimal_places)
|
||||
{
|
||||
QString s = QString::number(val, 'f', decimal_places);
|
||||
@@ -54,11 +54,11 @@ QString DecimalSliderBase::FloatToString(double val, int decimal_places,
|
||||
return s;
|
||||
}
|
||||
|
||||
void DecimalSliderBase::SetDecimalPlaces(int i)
|
||||
void DecimalSliderBase::set_decimal_places(int i)
|
||||
{
|
||||
decimal_places_ = i;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef DECIMALSLIDERBASE_H
|
||||
#define DECIMALSLIDERBASE_H
|
||||
#ifndef OAK_DECIMALSLIDERBASE_H
|
||||
#define OAK_DECIMALSLIDERBASE_H
|
||||
|
||||
#include "numericsliderbase.h"
|
||||
|
||||
@@ -31,19 +31,19 @@ class DecimalSliderBase : public NumericSliderBase {
|
||||
public:
|
||||
DecimalSliderBase(QWidget *parent = nullptr);
|
||||
|
||||
int GetDecimalPlaces() const
|
||||
int get_decimal_places() const
|
||||
{
|
||||
return decimal_places_;
|
||||
}
|
||||
void SetDecimalPlaces(int i);
|
||||
void set_decimal_places(int i);
|
||||
|
||||
bool GetAutoTrimDecimalPlaces() const
|
||||
bool get_auto_trim_decimal_places() const
|
||||
{
|
||||
return autotrim_decimal_places_;
|
||||
};
|
||||
void SetAutoTrimDecimalPlaces(bool e);
|
||||
void set_auto_trim_decimal_places(bool e);
|
||||
|
||||
static QString FloatToString(double val, int decimal_places,
|
||||
static QString float_to_string(double val, int decimal_places,
|
||||
bool autotrim_decimal_places);
|
||||
|
||||
private:
|
||||
@@ -54,4 +54,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // DECIMALSLIDERBASE_H
|
||||
#endif // OAK_DECIMALSLIDERBASE_H
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
bool NumericSliderBase::effects_slider_is_being_dragged_ = false;
|
||||
bool NumericSliderBase::effects_slider_is_being_dragged = false;
|
||||
|
||||
NumericSliderBase::NumericSliderBase(QWidget *parent)
|
||||
: SliderBase(parent)
|
||||
@@ -44,60 +44,60 @@ NumericSliderBase::NumericSliderBase(QWidget *parent)
|
||||
// Numeric sliders are draggable, so we have a cursor that indicates that
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
|
||||
connect(label(), &SliderLabel::LabelPressed, this,
|
||||
&NumericSliderBase::LabelPressed);
|
||||
connect(label(), &SliderLabel::label_pressed, this,
|
||||
&NumericSliderBase::label_pressed);
|
||||
}
|
||||
|
||||
void NumericSliderBase::SetDragMultiplier(const double &d)
|
||||
void NumericSliderBase::set_drag_multiplier(const double &d)
|
||||
{
|
||||
drag_multiplier_ = d;
|
||||
}
|
||||
|
||||
void NumericSliderBase::LabelPressed()
|
||||
void NumericSliderBase::label_pressed()
|
||||
{
|
||||
drag_ladder_ = new SliderLadder(drag_multiplier_, ladder_element_count_,
|
||||
GetFormattedValueToString(99999999));
|
||||
connect(drag_ladder_, &SliderLadder::DraggedByValue, this,
|
||||
&NumericSliderBase::LadderDragged);
|
||||
connect(drag_ladder_, &SliderLadder::Released, this,
|
||||
&NumericSliderBase::LadderReleased);
|
||||
get_formatted_value_to_string(99999999));
|
||||
connect(drag_ladder_, &SliderLadder::dragged_by_value, this,
|
||||
&NumericSliderBase::ladder_dragged);
|
||||
connect(drag_ladder_, &SliderLadder::released, this,
|
||||
&NumericSliderBase::ladder_released);
|
||||
|
||||
drag_ladder_->SetValue(GetFormattedValueToString());
|
||||
drag_ladder_->set_value(get_formatted_value_to_string());
|
||||
drag_ladder_->resize(drag_ladder_->sizeHint());
|
||||
RepositionLadder();
|
||||
reposition_ladder();
|
||||
drag_ladder_->show();
|
||||
|
||||
drag_start_value_ = GetValueInternal();
|
||||
drag_start_value_ = get_value_internal();
|
||||
}
|
||||
|
||||
void NumericSliderBase::LadderDragged(int value, double multiplier)
|
||||
void NumericSliderBase::ladder_dragged(int value, double multiplier)
|
||||
{
|
||||
dragged_ = true;
|
||||
|
||||
dragged_diff_ += value * multiplier;
|
||||
|
||||
// Store current value to try and prevent any unnecessary signalling if the value doesn't change
|
||||
QVariant pre_set_value = GetValueInternal();
|
||||
QVariant pre_set_value = get_value_internal();
|
||||
|
||||
setting_drag_value_ = true;
|
||||
SetValueInternal(
|
||||
AdjustDragDistanceInternal(drag_start_value_, dragged_diff_));
|
||||
set_value_internal(
|
||||
adjust_drag_distance_internal(drag_start_value_, dragged_diff_));
|
||||
setting_drag_value_ = false;
|
||||
|
||||
if (GetValueInternal() != pre_set_value) {
|
||||
if (get_value_internal() != pre_set_value) {
|
||||
// We retrieve the value instead of storing it ourselves because SetValueInternal may do extra
|
||||
// processing (such as clamping).
|
||||
drag_ladder_->SetValue(GetFormattedValueToString());
|
||||
drag_ladder_->set_value(get_formatted_value_to_string());
|
||||
|
||||
if (!UsingLadders()) {
|
||||
RepositionLadder();
|
||||
if (!using_ladders()) {
|
||||
reposition_ladder();
|
||||
}
|
||||
|
||||
ValueSignalEvent(GetValueInternal());
|
||||
value_signal_event(get_value_internal());
|
||||
}
|
||||
}
|
||||
|
||||
void NumericSliderBase::LadderReleased()
|
||||
void NumericSliderBase::ladder_released()
|
||||
{
|
||||
drag_ladder_->deleteLater();
|
||||
drag_ladder_ = nullptr;
|
||||
@@ -105,24 +105,24 @@ void NumericSliderBase::LadderReleased()
|
||||
|
||||
if (dragged_) {
|
||||
// This was a drag, send another value changed event
|
||||
ValueSignalEvent(GetValueInternal());
|
||||
value_signal_event(get_value_internal());
|
||||
|
||||
dragged_ = false;
|
||||
} else {
|
||||
ShowEditor();
|
||||
show_editor();
|
||||
}
|
||||
}
|
||||
|
||||
void NumericSliderBase::RepositionLadder()
|
||||
void NumericSliderBase::reposition_ladder()
|
||||
{
|
||||
if (drag_ladder_) {
|
||||
if (UsingLadders()) {
|
||||
if (using_ladders()) {
|
||||
drag_ladder_->move(
|
||||
QCursor::pos() -
|
||||
QPoint(drag_ladder_->width() / 2, drag_ladder_->height() / 2));
|
||||
} else {
|
||||
QPoint label_global_pos = label()->mapToGlobal(label()->pos());
|
||||
int text_width = QtUtils::QFontMetricsWidth(label()->fontMetrics(),
|
||||
int text_width = QtUtils::q_font_metrics_width(label()->fontMetrics(),
|
||||
label()->text());
|
||||
|
||||
if (label()->alignment() & Qt::AlignRight) {
|
||||
@@ -141,83 +141,83 @@ void NumericSliderBase::RepositionLadder()
|
||||
drag_ladder_->move(ladder_x, ladder_y);
|
||||
}
|
||||
|
||||
drag_ladder_->StartListeningToMouseInput();
|
||||
drag_ladder_->start_listening_to_mouse_input();
|
||||
}
|
||||
}
|
||||
|
||||
bool NumericSliderBase::IsDragging() const
|
||||
bool NumericSliderBase::is_dragging() const
|
||||
{
|
||||
return drag_ladder_;
|
||||
}
|
||||
|
||||
bool NumericSliderBase::UsingLadders() const
|
||||
bool NumericSliderBase::using_ladders() const
|
||||
{
|
||||
return ladder_element_count_ > 0 &&
|
||||
OLIVE_CONFIG("UseSliderLadders").toBool();
|
||||
OAK_CONFIG("UseSliderLadders").toBool();
|
||||
}
|
||||
|
||||
QVariant NumericSliderBase::AdjustValue(const QVariant &value) const
|
||||
QVariant NumericSliderBase::adjust_value(const QVariant &value) const
|
||||
{
|
||||
// Clamps between min/max
|
||||
if (has_min_ && ValueLessThan(value, min_value_)) {
|
||||
if (has_min_ && value_less_than(value, min_value_)) {
|
||||
return min_value_;
|
||||
} else if (has_max_ && ValueGreaterThan(value, max_value_)) {
|
||||
} else if (has_max_ && value_greater_than(value, max_value_)) {
|
||||
return max_value_;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void NumericSliderBase::SetOffset(const QVariant &v)
|
||||
void NumericSliderBase::set_offset(const QVariant &v)
|
||||
{
|
||||
offset_ = v;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
QVariant NumericSliderBase::AdjustDragDistanceInternal(const QVariant &start,
|
||||
QVariant NumericSliderBase::adjust_drag_distance_internal(const QVariant &start,
|
||||
const double &drag) const
|
||||
{
|
||||
return start.toDouble() + drag;
|
||||
}
|
||||
|
||||
void NumericSliderBase::SetMinimumInternal(const QVariant &v)
|
||||
void NumericSliderBase::set_minimum_internal(const QVariant &v)
|
||||
{
|
||||
min_value_ = v;
|
||||
has_min_ = true;
|
||||
|
||||
// Limit value by this new minimum value
|
||||
if (ValueLessThan(GetValueInternal(), min_value_)) {
|
||||
SetValueInternal(min_value_);
|
||||
if (value_less_than(get_value_internal(), min_value_)) {
|
||||
set_value_internal(min_value_);
|
||||
}
|
||||
}
|
||||
|
||||
void NumericSliderBase::SetMaximumInternal(const QVariant &v)
|
||||
void NumericSliderBase::set_maximum_internal(const QVariant &v)
|
||||
{
|
||||
max_value_ = v;
|
||||
has_max_ = true;
|
||||
|
||||
// Limit value by this new maximum value
|
||||
if (ValueGreaterThan(GetValueInternal(), max_value_)) {
|
||||
SetValueInternal(max_value_);
|
||||
if (value_greater_than(get_value_internal(), max_value_)) {
|
||||
set_value_internal(max_value_);
|
||||
}
|
||||
}
|
||||
|
||||
bool NumericSliderBase::ValueGreaterThan(const QVariant &lhs,
|
||||
bool NumericSliderBase::value_greater_than(const QVariant &lhs,
|
||||
const QVariant &rhs) const
|
||||
{
|
||||
return lhs.toDouble() > rhs.toDouble();
|
||||
}
|
||||
|
||||
bool NumericSliderBase::ValueLessThan(const QVariant &lhs,
|
||||
bool NumericSliderBase::value_less_than(const QVariant &lhs,
|
||||
const QVariant &rhs) const
|
||||
{
|
||||
return lhs.toDouble() < rhs.toDouble();
|
||||
}
|
||||
|
||||
bool NumericSliderBase::CanSetValue() const
|
||||
bool NumericSliderBase::can_set_value() const
|
||||
{
|
||||
return !IsDragging() || setting_drag_value_;
|
||||
return !is_dragging() || setting_drag_value_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NUMERICSLIDERBASE_H
|
||||
#define NUMERICSLIDERBASE_H
|
||||
#ifndef OAK_NUMERICSLIDERBASE_H
|
||||
#define OAK_NUMERICSLIDERBASE_H
|
||||
|
||||
#include "sliderbase.h"
|
||||
|
||||
@@ -32,41 +32,41 @@ class NumericSliderBase : public SliderBase {
|
||||
public:
|
||||
NumericSliderBase(QWidget *parent = nullptr);
|
||||
|
||||
void SetLadderElementCount(int b)
|
||||
void set_ladder_element_count(int b)
|
||||
{
|
||||
ladder_element_count_ = b;
|
||||
}
|
||||
|
||||
void SetDragMultiplier(const double &d);
|
||||
void set_drag_multiplier(const double &d);
|
||||
|
||||
void SetOffset(const QVariant &v);
|
||||
void set_offset(const QVariant &v);
|
||||
|
||||
bool IsDragging() const;
|
||||
bool is_dragging() const;
|
||||
|
||||
protected:
|
||||
const QVariant &GetOffset() const
|
||||
const QVariant &get_offset() const
|
||||
{
|
||||
return offset_;
|
||||
}
|
||||
|
||||
virtual QVariant AdjustDragDistanceInternal(const QVariant &start,
|
||||
virtual QVariant adjust_drag_distance_internal(const QVariant &start,
|
||||
const double &drag) const;
|
||||
|
||||
void SetMinimumInternal(const QVariant &v);
|
||||
void set_minimum_internal(const QVariant &v);
|
||||
|
||||
void SetMaximumInternal(const QVariant &v);
|
||||
void set_maximum_internal(const QVariant &v);
|
||||
|
||||
virtual bool ValueGreaterThan(const QVariant &lhs,
|
||||
virtual bool value_greater_than(const QVariant &lhs,
|
||||
const QVariant &rhs) const;
|
||||
|
||||
virtual bool ValueLessThan(const QVariant &lhs, const QVariant &rhs) const;
|
||||
virtual bool value_less_than(const QVariant &lhs, const QVariant &rhs) const;
|
||||
|
||||
virtual bool CanSetValue() const override;
|
||||
virtual bool can_set_value() const override;
|
||||
|
||||
private:
|
||||
bool UsingLadders() const;
|
||||
bool using_ladders() const;
|
||||
|
||||
virtual QVariant AdjustValue(const QVariant &value) const override;
|
||||
virtual QVariant adjust_value(const QVariant &value) const override;
|
||||
|
||||
SliderLadder *drag_ladder_;
|
||||
|
||||
@@ -93,18 +93,18 @@ private:
|
||||
/**
|
||||
* @brief An effects slider somewhere is being dragged
|
||||
*/
|
||||
static bool effects_slider_is_being_dragged_;
|
||||
static bool effects_slider_is_being_dragged;
|
||||
|
||||
private slots:
|
||||
void LabelPressed();
|
||||
void label_pressed();
|
||||
|
||||
void RepositionLadder();
|
||||
void reposition_ladder();
|
||||
|
||||
void LadderDragged(int value, double multiplier);
|
||||
void ladder_dragged(int value, double multiplier);
|
||||
|
||||
void LadderReleased();
|
||||
void ladder_released();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NUMERICSLIDERBASE_H
|
||||
#endif // OAK_NUMERICSLIDERBASE_H
|
||||
|
||||
@@ -50,51 +50,51 @@ SliderBase::SliderBase(QWidget *parent)
|
||||
editor_ = new FocusableLineEdit(this);
|
||||
addWidget(editor_);
|
||||
|
||||
connect(label_, &SliderLabel::focused, this, &SliderBase::ShowEditor);
|
||||
connect(label_, &SliderLabel::RequestReset, this, &SliderBase::ResetValue);
|
||||
connect(editor_, &FocusableLineEdit::Confirmed, this,
|
||||
&SliderBase::LineEditConfirmed);
|
||||
connect(editor_, &FocusableLineEdit::Cancelled, this,
|
||||
&SliderBase::LineEditCancelled);
|
||||
connect(label_, &SliderLabel::focused, this, &SliderBase::show_editor);
|
||||
connect(label_, &SliderLabel::request_reset, this, &SliderBase::reset_value);
|
||||
connect(editor_, &FocusableLineEdit::confirmed, this,
|
||||
&SliderBase::line_edit_confirmed);
|
||||
connect(editor_, &FocusableLineEdit::cancelled, this,
|
||||
&SliderBase::line_edit_cancelled);
|
||||
}
|
||||
|
||||
void SliderBase::SetAlignment(Qt::Alignment alignment)
|
||||
void SliderBase::set_alignment(Qt::Alignment alignment)
|
||||
{
|
||||
label_->setAlignment(alignment);
|
||||
editor_->setAlignment(alignment);
|
||||
}
|
||||
|
||||
bool SliderBase::IsTristate() const
|
||||
bool SliderBase::is_tristate() const
|
||||
{
|
||||
return tristate_;
|
||||
}
|
||||
|
||||
void SliderBase::SetTristate()
|
||||
void SliderBase::set_tristate()
|
||||
{
|
||||
tristate_ = true;
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
const QVariant &SliderBase::GetValueInternal() const
|
||||
const QVariant &SliderBase::get_value_internal() const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
void SliderBase::SetValueInternal(const QVariant &v)
|
||||
void SliderBase::set_value_internal(const QVariant &v)
|
||||
{
|
||||
if (!CanSetValue()) {
|
||||
if (!can_set_value()) {
|
||||
return;
|
||||
}
|
||||
|
||||
value_ = AdjustValue(v);
|
||||
value_ = adjust_value(v);
|
||||
|
||||
// Disable tristate
|
||||
tristate_ = false;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void SliderBase::SetDefaultValue(const QVariant &v)
|
||||
void SliderBase::set_default_value(const QVariant &v)
|
||||
{
|
||||
default_value_ = v;
|
||||
}
|
||||
@@ -102,12 +102,12 @@ void SliderBase::SetDefaultValue(const QVariant &v)
|
||||
void SliderBase::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
super::changeEvent(e);
|
||||
}
|
||||
|
||||
bool SliderBase::GetLabelSubstitution(const QVariant &v, QString *out) const
|
||||
bool SliderBase::get_label_substitution(const QVariant &v, QString *out) const
|
||||
{
|
||||
for (auto it = label_substitutions_.constBegin();
|
||||
it != label_substitutions_.constEnd(); it++) {
|
||||
@@ -120,41 +120,41 @@ bool SliderBase::GetLabelSubstitution(const QVariant &v, QString *out) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void SliderBase::UpdateLabel()
|
||||
void SliderBase::update_label()
|
||||
{
|
||||
QString s;
|
||||
|
||||
if (tristate_) {
|
||||
s = tr("---");
|
||||
} else if (GetLabelSubstitution(GetValueInternal(), &s)) {
|
||||
} else if (get_label_substitution(get_value_internal(), &s)) {
|
||||
// String will already be set, just pass through
|
||||
} else {
|
||||
s = GetFormattedValueToString();
|
||||
s = get_formatted_value_to_string();
|
||||
}
|
||||
|
||||
label_->setText(s);
|
||||
}
|
||||
|
||||
QVariant SliderBase::AdjustValue(const QVariant &value) const
|
||||
QVariant SliderBase::adjust_value(const QVariant &value) const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
bool SliderBase::CanSetValue() const
|
||||
bool SliderBase::can_set_value() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SliderBase::ValueSignalEvent(const QVariant &value)
|
||||
void SliderBase::value_signal_event(const QVariant &value)
|
||||
{
|
||||
Q_UNUSED(value)
|
||||
}
|
||||
|
||||
void SliderBase::ShowEditor()
|
||||
void SliderBase::show_editor()
|
||||
{
|
||||
// This was a simple click
|
||||
// Load label's text into editor
|
||||
editor_->setText(ValueToString(value_));
|
||||
editor_->setText(value_to_string(value_));
|
||||
|
||||
// Show editor
|
||||
setCurrentWidget(editor_);
|
||||
@@ -164,21 +164,21 @@ void SliderBase::ShowEditor()
|
||||
editor_->selectAll();
|
||||
}
|
||||
|
||||
void SliderBase::LineEditConfirmed()
|
||||
void SliderBase::line_edit_confirmed()
|
||||
{
|
||||
bool is_valid = true;
|
||||
QVariant test_val = StringToValue(editor_->text(), &is_valid);
|
||||
QVariant test_val = string_to_value(editor_->text(), &is_valid);
|
||||
|
||||
// Ensure editor doesn't signal that the focus is lost
|
||||
editor_->blockSignals(true);
|
||||
label_->blockSignals(true);
|
||||
|
||||
if (is_valid) {
|
||||
SetValueInternal(test_val);
|
||||
set_value_internal(test_val);
|
||||
|
||||
setCurrentWidget(label_);
|
||||
|
||||
ValueSignalEvent(value_);
|
||||
value_signal_event(value_);
|
||||
} else {
|
||||
QMessageBox::critical(
|
||||
this, tr("Invalid Value"),
|
||||
@@ -193,7 +193,7 @@ void SliderBase::LineEditConfirmed()
|
||||
label_->blockSignals(false);
|
||||
}
|
||||
|
||||
void SliderBase::LineEditCancelled()
|
||||
void SliderBase::line_edit_cancelled()
|
||||
{
|
||||
// Ensure editor doesn't signal that the focus is lost
|
||||
editor_->blockSignals(true);
|
||||
@@ -206,33 +206,33 @@ void SliderBase::LineEditCancelled()
|
||||
label_->blockSignals(false);
|
||||
}
|
||||
|
||||
void SliderBase::ResetValue()
|
||||
void SliderBase::reset_value()
|
||||
{
|
||||
if (default_value_.isValid()) {
|
||||
SetValueInternal(default_value_);
|
||||
ValueSignalEvent(value_);
|
||||
set_value_internal(default_value_);
|
||||
value_signal_event(value_);
|
||||
}
|
||||
}
|
||||
|
||||
void SliderBase::SetFormat(const QString &s, const bool plural)
|
||||
void SliderBase::set_format(const QString &s, const bool plural)
|
||||
{
|
||||
custom_format_ = s;
|
||||
format_plural_ = plural;
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void SliderBase::ClearFormat()
|
||||
void SliderBase::clear_format()
|
||||
{
|
||||
custom_format_.clear();
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
bool SliderBase::IsFormatPlural() const
|
||||
bool SliderBase::is_format_plural() const
|
||||
{
|
||||
return format_plural_;
|
||||
}
|
||||
|
||||
QString SliderBase::GetFormat() const
|
||||
QString SliderBase::get_format() const
|
||||
{
|
||||
if (custom_format_.isEmpty()) {
|
||||
return QStringLiteral("%1");
|
||||
@@ -241,17 +241,17 @@ QString SliderBase::GetFormat() const
|
||||
}
|
||||
}
|
||||
|
||||
QString SliderBase::GetFormattedValueToString() const
|
||||
QString SliderBase::get_formatted_value_to_string() const
|
||||
{
|
||||
return GetFormattedValueToString(GetValueInternal());
|
||||
return get_formatted_value_to_string(get_value_internal());
|
||||
}
|
||||
|
||||
QString SliderBase::GetFormattedValueToString(const QVariant &v) const
|
||||
QString SliderBase::get_formatted_value_to_string(const QVariant &v) const
|
||||
{
|
||||
if (format_plural_) {
|
||||
return tr(GetFormat().toUtf8().constData(), nullptr, v.toInt());
|
||||
return tr(get_format().toUtf8().constData(), nullptr, v.toInt());
|
||||
} else {
|
||||
return GetFormat().arg(ValueToString(v));
|
||||
return get_format().arg(value_to_string(v));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SLIDERBASE_H
|
||||
#define SLIDERBASE_H
|
||||
#ifndef OAK_SLIDERBASE_H
|
||||
#define OAK_SLIDERBASE_H
|
||||
|
||||
#include <QStackedWidget>
|
||||
|
||||
@@ -36,65 +36,65 @@ class SliderBase : public QStackedWidget {
|
||||
public:
|
||||
SliderBase(QWidget *parent = nullptr);
|
||||
|
||||
void SetAlignment(Qt::Alignment alignment);
|
||||
void set_alignment(Qt::Alignment alignment);
|
||||
|
||||
bool IsTristate() const;
|
||||
void SetTristate();
|
||||
bool is_tristate() const;
|
||||
void set_tristate();
|
||||
|
||||
void SetFormat(const QString &s, const bool plural = false);
|
||||
void ClearFormat();
|
||||
void set_format(const QString &s, const bool plural = false);
|
||||
void clear_format();
|
||||
|
||||
bool IsFormatPlural() const;
|
||||
bool is_format_plural() const;
|
||||
|
||||
void SetDefaultValue(const QVariant &v);
|
||||
void set_default_value(const QVariant &v);
|
||||
|
||||
QString GetFormattedValueToString(const QVariant &v) const;
|
||||
QString get_formatted_value_to_string(const QVariant &v) const;
|
||||
|
||||
void InsertLabelSubstitution(const QVariant &value, const QString &label)
|
||||
void insert_label_substitution(const QVariant &value, const QString &label)
|
||||
{
|
||||
label_substitutions_.append({ value, label });
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void SetColor(const QColor &c)
|
||||
void set_color(const QColor &c)
|
||||
{
|
||||
label_->SetColor(c);
|
||||
label_->set_color(c);
|
||||
}
|
||||
|
||||
public slots:
|
||||
void ShowEditor();
|
||||
void show_editor();
|
||||
|
||||
protected slots:
|
||||
void UpdateLabel();
|
||||
void update_label();
|
||||
|
||||
protected:
|
||||
const QVariant &GetValueInternal() const;
|
||||
const QVariant &get_value_internal() const;
|
||||
|
||||
void SetValueInternal(const QVariant &v);
|
||||
void set_value_internal(const QVariant &v);
|
||||
|
||||
QString GetFormat() const;
|
||||
QString get_format() const;
|
||||
|
||||
QString GetFormattedValueToString() const;
|
||||
QString get_formatted_value_to_string() const;
|
||||
|
||||
SliderLabel *label()
|
||||
{
|
||||
return label_;
|
||||
}
|
||||
|
||||
virtual QString ValueToString(const QVariant &v) const = 0;
|
||||
virtual QString value_to_string(const QVariant &v) const = 0;
|
||||
|
||||
virtual QVariant StringToValue(const QString &s, bool *ok) const = 0;
|
||||
virtual QVariant string_to_value(const QString &s, bool *ok) const = 0;
|
||||
|
||||
virtual QVariant AdjustValue(const QVariant &value) const;
|
||||
virtual QVariant adjust_value(const QVariant &value) const;
|
||||
|
||||
virtual bool CanSetValue() const;
|
||||
virtual bool can_set_value() const;
|
||||
|
||||
virtual void ValueSignalEvent(const QVariant &value) = 0;
|
||||
virtual void value_signal_event(const QVariant &value) = 0;
|
||||
|
||||
virtual void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
bool GetLabelSubstitution(const QVariant &v, QString *out) const;
|
||||
bool get_label_substitution(const QVariant &v, QString *out) const;
|
||||
|
||||
SliderLabel *label_;
|
||||
|
||||
@@ -112,13 +112,13 @@ private:
|
||||
QVector<QPair<QVariant, QString>> label_substitutions_;
|
||||
|
||||
private slots:
|
||||
void LineEditConfirmed();
|
||||
void line_edit_confirmed();
|
||||
|
||||
void LineEditCancelled();
|
||||
void line_edit_cancelled();
|
||||
|
||||
void ResetValue();
|
||||
void reset_value();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SLIDERBASE_H
|
||||
#endif // OAK_SLIDERBASE_H
|
||||
|
||||
@@ -54,7 +54,7 @@ SliderLabel::SliderLabel(QWidget *parent)
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
}
|
||||
|
||||
void SliderLabel::SetColor(const QColor &c)
|
||||
void SliderLabel::set_color(const QColor &c)
|
||||
{
|
||||
// Prevent infinite loop in changeEvent when we set the stylesheet
|
||||
override_color_enabled_ = false;
|
||||
@@ -78,9 +78,9 @@ void SliderLabel::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
if (e->modifiers() & Qt::AltModifier) {
|
||||
emit RequestReset();
|
||||
emit request_reset();
|
||||
} else {
|
||||
emit LabelPressed();
|
||||
emit label_pressed();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ void SliderLabel::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
if (!(e->modifiers() & Qt::AltModifier)) {
|
||||
emit LabelReleased();
|
||||
emit label_released();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ void SliderLabel::changeEvent(QEvent *event)
|
||||
QWidget::changeEvent(event);
|
||||
|
||||
if (override_color_enabled_ && event->type() == QEvent::StyleChange) {
|
||||
SetColor(override_color_);
|
||||
set_color(override_color_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SLIDERLABEL_H
|
||||
#define SLIDERLABEL_H
|
||||
#ifndef OAK_SLIDERLABEL_H
|
||||
#define OAK_SLIDERLABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
@@ -34,7 +34,7 @@ class SliderLabel : public QLabel {
|
||||
public:
|
||||
SliderLabel(QWidget *parent);
|
||||
|
||||
void SetColor(const QColor &c);
|
||||
void set_color(const QColor &c);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent *e) override;
|
||||
@@ -46,15 +46,15 @@ protected:
|
||||
virtual void changeEvent(QEvent *event) override;
|
||||
|
||||
signals:
|
||||
void LabelPressed();
|
||||
void label_pressed();
|
||||
|
||||
void LabelReleased();
|
||||
void label_released();
|
||||
|
||||
void focused();
|
||||
|
||||
void RequestReset();
|
||||
void request_reset();
|
||||
|
||||
void ChangeSliderType();
|
||||
void change_slider_type();
|
||||
|
||||
private:
|
||||
bool override_color_enabled_;
|
||||
@@ -63,4 +63,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // SLIDERLABEL_H
|
||||
#endif // OAK_SLIDERLABEL_H
|
||||
|
||||
@@ -50,7 +50,7 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values,
|
||||
setFrameShape(QFrame::Box);
|
||||
setLineWidth(1);
|
||||
|
||||
if (!OLIVE_CONFIG("UseSliderLadders").toBool()) {
|
||||
if (!OAK_CONFIG("UseSliderLadders").toBool()) {
|
||||
nb_outer_values = 0;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values,
|
||||
SliderLadderElement *start_element =
|
||||
new SliderLadderElement(drag_multiplier, width_hint);
|
||||
active_element_ = elements_.size();
|
||||
start_element->SetHighlighted(true);
|
||||
start_element->set_highlighted(true);
|
||||
elements_.append(start_element);
|
||||
|
||||
for (int i = 0; i < nb_outer_values; i++) {
|
||||
@@ -76,11 +76,11 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values,
|
||||
}
|
||||
|
||||
if (elements_.size() == 1) {
|
||||
elements_.first()->SetMultiplierVisible(false);
|
||||
elements_.first()->set_multiplier_visible(false);
|
||||
}
|
||||
|
||||
drag_timer_.setInterval(10);
|
||||
connect(&drag_timer_, &QTimer::timeout, this, &SliderLadder::TimerUpdate);
|
||||
connect(&drag_timer_, &QTimer::timeout, this, &SliderLadder::timer_update);
|
||||
|
||||
screen_ = nullptr;
|
||||
foreach (QScreen *screen, qApp->screens()) {
|
||||
@@ -90,7 +90,7 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values,
|
||||
}
|
||||
}
|
||||
|
||||
if (UsingLadders()) {
|
||||
if (using_ladders()) {
|
||||
drag_start_x_ = -1;
|
||||
wrap_count_ = 0;
|
||||
} else {
|
||||
@@ -110,7 +110,7 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values,
|
||||
|
||||
SliderLadder::~SliderLadder()
|
||||
{
|
||||
if (UsingLadders()) {
|
||||
if (using_ladders()) {
|
||||
if (wrap_count_ != 0) {
|
||||
// If wrapped, restore cursor to ladder
|
||||
QCursor::setPos(pos() + rect().center());
|
||||
@@ -126,14 +126,14 @@ SliderLadder::~SliderLadder()
|
||||
}
|
||||
}
|
||||
|
||||
void SliderLadder::SetValue(const QString &s)
|
||||
void SliderLadder::set_value(const QString &s)
|
||||
{
|
||||
foreach (SliderLadderElement *e, elements_) {
|
||||
e->SetValue(s);
|
||||
e->set_value(s);
|
||||
}
|
||||
}
|
||||
|
||||
void SliderLadder::StartListeningToMouseInput()
|
||||
void SliderLadder::start_listening_to_mouse_input()
|
||||
{
|
||||
QMetaObject::invokeMethod(&drag_timer_, "start", Qt::QueuedConnection);
|
||||
}
|
||||
@@ -151,18 +151,18 @@ void SliderLadder::closeEvent(QCloseEvent *event)
|
||||
|
||||
drag_timer_.stop();
|
||||
|
||||
emit Released();
|
||||
emit released();
|
||||
|
||||
QFrame::closeEvent(event);
|
||||
}
|
||||
|
||||
void SliderLadder::TimerUpdate()
|
||||
void SliderLadder::timer_update()
|
||||
{
|
||||
int ladder_left = this->x();
|
||||
int ladder_right = this->x() + this->width() - 1;
|
||||
int now_pos = QCursor::pos().x();
|
||||
|
||||
if (UsingLadders()) {
|
||||
if (using_ladders()) {
|
||||
bool is_under_mouse = (now_pos >= ladder_left &&
|
||||
now_pos <= ladder_right && wrap_count_ == 0);
|
||||
|
||||
@@ -180,8 +180,8 @@ void SliderLadder::TimerUpdate()
|
||||
}
|
||||
|
||||
int makeup_value = anchor - drag_start_x_;
|
||||
emit DraggedByValue(makeup_value,
|
||||
elements_.at(active_element_)->GetMultiplier());
|
||||
emit dragged_by_value(makeup_value,
|
||||
elements_.at(active_element_)->get_multiplier());
|
||||
|
||||
drag_start_x_ = -1;
|
||||
}
|
||||
@@ -191,9 +191,9 @@ void SliderLadder::TimerUpdate()
|
||||
for (int i = 0; i < elements_.size(); i++) {
|
||||
if (elements_.at(i)->underMouse()) {
|
||||
if (i != active_element_) {
|
||||
elements_.at(active_element_)->SetHighlighted(false);
|
||||
elements_.at(active_element_)->set_highlighted(false);
|
||||
active_element_ = i;
|
||||
elements_.at(active_element_)->SetHighlighted(true);
|
||||
elements_.at(active_element_)->set_highlighted(true);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -210,8 +210,8 @@ void SliderLadder::TimerUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
emit DraggedByValue(now_pos - drag_start_x_,
|
||||
elements_.at(active_element_)->GetMultiplier());
|
||||
emit dragged_by_value(now_pos - drag_start_x_,
|
||||
elements_.at(active_element_)->get_multiplier());
|
||||
|
||||
// Determine if cursor is at desktop edge, if so wrap around to other side
|
||||
if (screen_) {
|
||||
@@ -268,12 +268,12 @@ void SliderLadder::TimerUpdate()
|
||||
multiplier *= 100.0;
|
||||
}
|
||||
|
||||
emit DraggedByValue(x_mvmt + y_mvmt, multiplier);
|
||||
emit dragged_by_value(x_mvmt + y_mvmt, multiplier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SliderLadder::UsingLadders() const
|
||||
bool SliderLadder::using_ladders() const
|
||||
{
|
||||
return elements_.size() > 1;
|
||||
}
|
||||
@@ -290,7 +290,7 @@ SliderLadderElement::SliderLadderElement(const double &multiplier,
|
||||
label_ = new QLabel();
|
||||
label_->setAlignment(Qt::AlignCenter);
|
||||
label_->setFixedWidth(
|
||||
QtUtils::QFontMetricsWidth(label_->fontMetrics(), width_hint));
|
||||
QtUtils::q_font_metrics_width(label_->fontMetrics(), width_hint));
|
||||
layout->addWidget(label_);
|
||||
|
||||
QPalette p = palette();
|
||||
@@ -301,10 +301,10 @@ SliderLadderElement::SliderLadderElement(const double &multiplier,
|
||||
|
||||
setAutoFillBackground(true);
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void SliderLadderElement::SetHighlighted(bool e)
|
||||
void SliderLadderElement::set_highlighted(bool e)
|
||||
{
|
||||
highlighted_ = e;
|
||||
|
||||
@@ -314,24 +314,24 @@ void SliderLadderElement::SetHighlighted(bool e)
|
||||
setBackgroundRole(QPalette::Window);
|
||||
}
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void SliderLadderElement::SetValue(const QString &value)
|
||||
void SliderLadderElement::set_value(const QString &value)
|
||||
{
|
||||
value_ = value;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void SliderLadderElement::SetMultiplierVisible(bool e)
|
||||
void SliderLadderElement::set_multiplier_visible(bool e)
|
||||
{
|
||||
multiplier_visible_ = e;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void SliderLadderElement::UpdateLabel()
|
||||
void SliderLadderElement::update_label()
|
||||
{
|
||||
if (multiplier_visible_) {
|
||||
QString val_text;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SLIDERLADDER_H
|
||||
#define SLIDERLADDER_H
|
||||
#ifndef OAK_SLIDERLADDER_H
|
||||
#define OAK_SLIDERLADDER_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
@@ -37,19 +37,19 @@ public:
|
||||
SliderLadderElement(const double &multiplier, QString width_hint,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
void SetHighlighted(bool e);
|
||||
void set_highlighted(bool e);
|
||||
|
||||
void SetValue(const QString &value);
|
||||
void set_value(const QString &value);
|
||||
|
||||
void SetMultiplierVisible(bool e);
|
||||
void set_multiplier_visible(bool e);
|
||||
|
||||
double GetMultiplier() const
|
||||
double get_multiplier() const
|
||||
{
|
||||
return multiplier_;
|
||||
}
|
||||
|
||||
private:
|
||||
void UpdateLabel();
|
||||
void update_label();
|
||||
|
||||
QLabel *label_;
|
||||
|
||||
@@ -69,9 +69,9 @@ public:
|
||||
|
||||
virtual ~SliderLadder() override;
|
||||
|
||||
void SetValue(const QString &s);
|
||||
void set_value(const QString &s);
|
||||
|
||||
void StartListeningToMouseInput();
|
||||
void start_listening_to_mouse_input();
|
||||
|
||||
protected:
|
||||
virtual void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
@@ -79,12 +79,12 @@ protected:
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
signals:
|
||||
void DraggedByValue(int value, double multiplier);
|
||||
void dragged_by_value(int value, double multiplier);
|
||||
|
||||
void Released();
|
||||
void released();
|
||||
|
||||
private:
|
||||
bool UsingLadders() const;
|
||||
bool using_ladders() const;
|
||||
|
||||
int drag_start_x_;
|
||||
int drag_start_y_;
|
||||
@@ -99,9 +99,9 @@ private:
|
||||
QScreen *screen_;
|
||||
|
||||
private slots:
|
||||
void TimerUpdate();
|
||||
void timer_update();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SLIDERLADDER_H
|
||||
#endif // OAK_SLIDERLADDER_H
|
||||
|
||||
@@ -33,62 +33,62 @@ namespace olive
|
||||
|
||||
FloatSlider::FloatSlider(QWidget *parent)
|
||||
: super(parent)
|
||||
, display_type_(kNormal)
|
||||
, display_type_(k_normal)
|
||||
{
|
||||
SetValue(0.0);
|
||||
set_value(0.0);
|
||||
}
|
||||
|
||||
double FloatSlider::GetValue() const
|
||||
double FloatSlider::get_value() const
|
||||
{
|
||||
return GetValueInternal().toDouble();
|
||||
return get_value_internal().toDouble();
|
||||
}
|
||||
|
||||
void FloatSlider::SetValue(const double &d)
|
||||
void FloatSlider::set_value(const double &d)
|
||||
{
|
||||
SetValueInternal(d);
|
||||
set_value_internal(d);
|
||||
}
|
||||
|
||||
void FloatSlider::SetDefaultValue(const double &d)
|
||||
{
|
||||
super::SetDefaultValue(d);
|
||||
super::set_default_value(d);
|
||||
}
|
||||
|
||||
void FloatSlider::SetMinimum(const double &d)
|
||||
void FloatSlider::set_minimum(const double &d)
|
||||
{
|
||||
SetMinimumInternal(d);
|
||||
set_minimum_internal(d);
|
||||
}
|
||||
|
||||
void FloatSlider::SetMaximum(const double &d)
|
||||
void FloatSlider::set_maximum(const double &d)
|
||||
{
|
||||
SetMaximumInternal(d);
|
||||
set_maximum_internal(d);
|
||||
}
|
||||
|
||||
void FloatSlider::SetDisplayType(const FloatSlider::DisplayType &type)
|
||||
void FloatSlider::set_display_type(const FloatSlider::DisplayType &type)
|
||||
{
|
||||
display_type_ = type;
|
||||
|
||||
switch (display_type_) {
|
||||
case kNormal:
|
||||
ClearFormat();
|
||||
case k_normal:
|
||||
clear_format();
|
||||
break;
|
||||
case kDecibel:
|
||||
SetFormat(tr("%1 dB"));
|
||||
case k_decibel:
|
||||
set_format(tr("%1 dB"));
|
||||
break;
|
||||
case kPercentage:
|
||||
SetFormat(tr("%1%"));
|
||||
case k_percentage:
|
||||
set_format(tr("%1%"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double FloatSlider::TransformValueToDisplay(double val, DisplayType display)
|
||||
double FloatSlider::transform_value_to_display(double val, DisplayType display)
|
||||
{
|
||||
switch (display) {
|
||||
case kNormal:
|
||||
case k_normal:
|
||||
break;
|
||||
case kDecibel:
|
||||
val = Decibel::fromLinear(val);
|
||||
case k_decibel:
|
||||
val = Decibel::from_linear(val);
|
||||
break;
|
||||
case kPercentage:
|
||||
case k_percentage:
|
||||
val *= 100.0;
|
||||
break;
|
||||
}
|
||||
@@ -96,15 +96,15 @@ double FloatSlider::TransformValueToDisplay(double val, DisplayType display)
|
||||
return val;
|
||||
}
|
||||
|
||||
double FloatSlider::TransformDisplayToValue(double val, DisplayType display)
|
||||
double FloatSlider::transform_display_to_value(double val, DisplayType display)
|
||||
{
|
||||
switch (display) {
|
||||
case kNormal:
|
||||
case k_normal:
|
||||
break;
|
||||
case kDecibel:
|
||||
val = Decibel::toLinear(val);
|
||||
case k_decibel:
|
||||
val = Decibel::to_linear(val);
|
||||
break;
|
||||
case kPercentage:
|
||||
case k_percentage:
|
||||
val *= 0.01;
|
||||
break;
|
||||
}
|
||||
@@ -112,26 +112,26 @@ double FloatSlider::TransformDisplayToValue(double val, DisplayType display)
|
||||
return val;
|
||||
}
|
||||
|
||||
QString FloatSlider::ValueToString(double val, FloatSlider::DisplayType display,
|
||||
QString FloatSlider::value_to_string(double val, FloatSlider::DisplayType display,
|
||||
int decimal_places,
|
||||
bool autotrim_decimal_places)
|
||||
{
|
||||
// Return negative infinity for zero volume
|
||||
if (display == kDecibel && qIsNull(val)) {
|
||||
if (display == k_decibel && qIsNull(val)) {
|
||||
return tr("\xE2\x88\x9E");
|
||||
}
|
||||
|
||||
return FloatToString(TransformValueToDisplay(val, display), decimal_places,
|
||||
return float_to_string(transform_value_to_display(val, display), decimal_places,
|
||||
autotrim_decimal_places);
|
||||
}
|
||||
|
||||
QString FloatSlider::ValueToString(const QVariant &v) const
|
||||
QString FloatSlider::value_to_string(const QVariant &v) const
|
||||
{
|
||||
return ValueToString(v.toDouble() + GetOffset().toDouble(), display_type_,
|
||||
GetDecimalPlaces(), GetAutoTrimDecimalPlaces());
|
||||
return value_to_string(v.toDouble() + get_offset().toDouble(), display_type_,
|
||||
get_decimal_places(), get_auto_trim_decimal_places());
|
||||
}
|
||||
|
||||
QVariant FloatSlider::StringToValue(const QString &s, bool *ok) const
|
||||
QVariant FloatSlider::string_to_value(const QString &s, bool *ok) const
|
||||
{
|
||||
bool valid;
|
||||
double val = s.toDouble(&valid);
|
||||
@@ -143,37 +143,37 @@ QVariant FloatSlider::StringToValue(const QString &s, bool *ok) const
|
||||
|
||||
// If valid, transform it from display
|
||||
if (valid) {
|
||||
val = TransformDisplayToValue(val, display_type_);
|
||||
val = transform_display_to_value(val, display_type_);
|
||||
}
|
||||
|
||||
// Return un-offset value
|
||||
return val - GetOffset().toDouble();
|
||||
return val - get_offset().toDouble();
|
||||
}
|
||||
|
||||
QVariant FloatSlider::AdjustDragDistanceInternal(const QVariant &start,
|
||||
QVariant FloatSlider::adjust_drag_distance_internal(const QVariant &start,
|
||||
const double &drag) const
|
||||
{
|
||||
switch (display_type_) {
|
||||
case kNormal:
|
||||
case k_normal:
|
||||
// No change here
|
||||
break;
|
||||
case kDecibel: {
|
||||
double current_db = Decibel::fromLinear(start.toDouble());
|
||||
case k_decibel: {
|
||||
double current_db = Decibel::from_linear(start.toDouble());
|
||||
current_db += drag;
|
||||
double adjusted_linear = Decibel::toLinear(current_db);
|
||||
double adjusted_linear = Decibel::to_linear(current_db);
|
||||
|
||||
return adjusted_linear;
|
||||
}
|
||||
case kPercentage:
|
||||
return super::AdjustDragDistanceInternal(start, drag * 0.01);
|
||||
case k_percentage:
|
||||
return super::adjust_drag_distance_internal(start, drag * 0.01);
|
||||
}
|
||||
|
||||
return super::AdjustDragDistanceInternal(start, drag);
|
||||
return super::adjust_drag_distance_internal(start, drag);
|
||||
}
|
||||
|
||||
void FloatSlider::ValueSignalEvent(const QVariant &value)
|
||||
void FloatSlider::value_signal_event(const QVariant &value)
|
||||
{
|
||||
emit ValueChanged(value.toDouble());
|
||||
emit value_changed(value.toDouble());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef FLOATSLIDER_H
|
||||
#define FLOATSLIDER_H
|
||||
#ifndef OAK_FLOATSLIDER_H
|
||||
#define OAK_FLOATSLIDER_H
|
||||
|
||||
#include "base/decimalsliderbase.h"
|
||||
|
||||
@@ -32,41 +32,41 @@ class FloatSlider : public DecimalSliderBase {
|
||||
public:
|
||||
FloatSlider(QWidget *parent = nullptr);
|
||||
|
||||
enum DisplayType { kNormal, kDecibel, kPercentage };
|
||||
enum DisplayType { k_normal, k_decibel, k_percentage };
|
||||
|
||||
double GetValue() const;
|
||||
double get_value() const;
|
||||
|
||||
void SetValue(const double &d);
|
||||
void set_value(const double &d);
|
||||
|
||||
void SetDefaultValue(const double &d);
|
||||
|
||||
void SetMinimum(const double &d);
|
||||
void set_minimum(const double &d);
|
||||
|
||||
void SetMaximum(const double &d);
|
||||
void set_maximum(const double &d);
|
||||
|
||||
void SetDisplayType(const DisplayType &type);
|
||||
void set_display_type(const DisplayType &type);
|
||||
|
||||
static double TransformValueToDisplay(double val, DisplayType display);
|
||||
static double transform_value_to_display(double val, DisplayType display);
|
||||
|
||||
static double TransformDisplayToValue(double val, DisplayType display);
|
||||
static double transform_display_to_value(double val, DisplayType display);
|
||||
|
||||
static QString ValueToString(double val, DisplayType display,
|
||||
static QString value_to_string(double val, DisplayType display,
|
||||
int decimal_places,
|
||||
bool autotrim_decimal_places);
|
||||
|
||||
protected:
|
||||
virtual QString ValueToString(const QVariant &v) const override;
|
||||
virtual QString value_to_string(const QVariant &v) const override;
|
||||
|
||||
virtual QVariant StringToValue(const QString &s, bool *ok) const override;
|
||||
virtual QVariant string_to_value(const QString &s, bool *ok) const override;
|
||||
|
||||
virtual QVariant
|
||||
AdjustDragDistanceInternal(const QVariant &start,
|
||||
adjust_drag_distance_internal(const QVariant &start,
|
||||
const double &drag) const override;
|
||||
|
||||
virtual void ValueSignalEvent(const QVariant &value) override;
|
||||
virtual void value_signal_event(const QVariant &value) override;
|
||||
|
||||
signals:
|
||||
void ValueChanged(double);
|
||||
void value_changed(double);
|
||||
|
||||
private:
|
||||
DisplayType display_type_;
|
||||
@@ -74,4 +74,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // FLOATSLIDER_H
|
||||
#endif // OAK_FLOATSLIDER_H
|
||||
|
||||
@@ -29,40 +29,40 @@ namespace olive
|
||||
IntegerSlider::IntegerSlider(QWidget *parent)
|
||||
: super(parent)
|
||||
{
|
||||
SetValue(0);
|
||||
set_value(0);
|
||||
}
|
||||
|
||||
int64_t IntegerSlider::GetValue()
|
||||
int64_t IntegerSlider::get_value()
|
||||
{
|
||||
return GetValueInternal().toLongLong();
|
||||
return get_value_internal().toLongLong();
|
||||
}
|
||||
|
||||
void IntegerSlider::SetValue(const int64_t &v)
|
||||
void IntegerSlider::set_value(const int64_t &v)
|
||||
{
|
||||
SetValueInternal(QVariant::fromValue(v));
|
||||
set_value_internal(QVariant::fromValue(v));
|
||||
}
|
||||
|
||||
void IntegerSlider::SetMinimum(const int64_t &d)
|
||||
void IntegerSlider::set_minimum(const int64_t &d)
|
||||
{
|
||||
SetMinimumInternal(QVariant::fromValue(d));
|
||||
set_minimum_internal(QVariant::fromValue(d));
|
||||
}
|
||||
|
||||
void IntegerSlider::SetMaximum(const int64_t &d)
|
||||
void IntegerSlider::set_maximum(const int64_t &d)
|
||||
{
|
||||
SetMaximumInternal(QVariant::fromValue(d));
|
||||
set_maximum_internal(QVariant::fromValue(d));
|
||||
}
|
||||
|
||||
void IntegerSlider::SetDefaultValue(const int64_t &d)
|
||||
{
|
||||
super::SetDefaultValue(QVariant::fromValue(d));
|
||||
super::set_default_value(QVariant::fromValue(d));
|
||||
}
|
||||
|
||||
QString IntegerSlider::ValueToString(const QVariant &v) const
|
||||
QString IntegerSlider::value_to_string(const QVariant &v) const
|
||||
{
|
||||
return QString::number(v.toLongLong() + GetOffset().toLongLong());
|
||||
return QString::number(v.toLongLong() + get_offset().toLongLong());
|
||||
}
|
||||
|
||||
QVariant IntegerSlider::StringToValue(const QString &s, bool *ok) const
|
||||
QVariant IntegerSlider::string_to_value(const QString &s, bool *ok) const
|
||||
{
|
||||
bool valid;
|
||||
|
||||
@@ -73,7 +73,7 @@ QVariant IntegerSlider::StringToValue(const QString &s, bool *ok) const
|
||||
*ok = valid;
|
||||
}
|
||||
|
||||
decimal_val -= GetOffset().toLongLong();
|
||||
decimal_val -= get_offset().toLongLong();
|
||||
|
||||
if (valid) {
|
||||
// But for an integer, we round it
|
||||
@@ -83,15 +83,15 @@ QVariant IntegerSlider::StringToValue(const QString &s, bool *ok) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void IntegerSlider::ValueSignalEvent(const QVariant &value)
|
||||
void IntegerSlider::value_signal_event(const QVariant &value)
|
||||
{
|
||||
emit ValueChanged(value.toInt());
|
||||
emit value_changed(value.toInt());
|
||||
}
|
||||
|
||||
QVariant IntegerSlider::AdjustDragDistanceInternal(const QVariant &start,
|
||||
QVariant IntegerSlider::adjust_drag_distance_internal(const QVariant &start,
|
||||
const double &drag) const
|
||||
{
|
||||
return qRound64(super::AdjustDragDistanceInternal(start, drag).toDouble());
|
||||
return qRound64(super::adjust_drag_distance_internal(start, drag).toDouble());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef INTEGERSLIDER_H
|
||||
#define INTEGERSLIDER_H
|
||||
#ifndef OAK_INTEGERSLIDER_H
|
||||
#define OAK_INTEGERSLIDER_H
|
||||
|
||||
#include "base/numericsliderbase.h"
|
||||
|
||||
@@ -32,31 +32,31 @@ class IntegerSlider : public NumericSliderBase {
|
||||
public:
|
||||
IntegerSlider(QWidget *parent = nullptr);
|
||||
|
||||
int64_t GetValue();
|
||||
int64_t get_value();
|
||||
|
||||
void SetValue(const int64_t &v);
|
||||
void set_value(const int64_t &v);
|
||||
|
||||
void SetMinimum(const int64_t &d);
|
||||
void set_minimum(const int64_t &d);
|
||||
|
||||
void SetMaximum(const int64_t &d);
|
||||
void set_maximum(const int64_t &d);
|
||||
|
||||
void SetDefaultValue(const int64_t &d);
|
||||
|
||||
protected:
|
||||
virtual QString ValueToString(const QVariant &v) const override;
|
||||
virtual QString value_to_string(const QVariant &v) const override;
|
||||
|
||||
virtual QVariant StringToValue(const QString &s, bool *ok) const override;
|
||||
virtual QVariant string_to_value(const QString &s, bool *ok) const override;
|
||||
|
||||
virtual void ValueSignalEvent(const QVariant &value) override;
|
||||
virtual void value_signal_event(const QVariant &value) override;
|
||||
|
||||
virtual QVariant
|
||||
AdjustDragDistanceInternal(const QVariant &start,
|
||||
adjust_drag_distance_internal(const QVariant &start,
|
||||
const double &drag) const override;
|
||||
|
||||
signals:
|
||||
void ValueChanged(int64_t);
|
||||
void value_changed(int64_t);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // INTEGERSLIDER_H
|
||||
#endif // OAK_INTEGERSLIDER_H
|
||||
|
||||
@@ -34,200 +34,200 @@ RationalSlider::RationalSlider(QWidget *parent)
|
||||
: super(parent)
|
||||
, lock_display_type_(false)
|
||||
{
|
||||
connect(Core::instance(), &Core::TimecodeDisplayChanged, this,
|
||||
&RationalSlider::UpdateLabel);
|
||||
connect(Core::instance(), &Core::timecode_display_changed, this,
|
||||
&RationalSlider::update_label);
|
||||
connect(SliderBase::label(), &SliderLabel::customContextMenuRequested, this,
|
||||
&RationalSlider::ShowDisplayTypeMenu);
|
||||
&RationalSlider::show_display_type_menu);
|
||||
|
||||
SetDisplayType(kFloat);
|
||||
set_display_type(k_float);
|
||||
|
||||
SetValue(rational(0, 0));
|
||||
set_value(Rational(0, 0));
|
||||
}
|
||||
|
||||
rational RationalSlider::GetValue()
|
||||
Rational RationalSlider::get_value()
|
||||
{
|
||||
return GetValueInternal().value<rational>();
|
||||
return get_value_internal().value<Rational>();
|
||||
}
|
||||
|
||||
void RationalSlider::SetValue(const rational &d)
|
||||
void RationalSlider::set_value(const Rational &d)
|
||||
{
|
||||
SetValueInternal(QVariant::fromValue(d));
|
||||
set_value_internal(QVariant::fromValue(d));
|
||||
}
|
||||
|
||||
void RationalSlider::SetDefaultValue(const rational &r)
|
||||
void RationalSlider::SetDefaultValue(const Rational &r)
|
||||
{
|
||||
super::SetDefaultValue(QVariant::fromValue(r));
|
||||
super::set_default_value(QVariant::fromValue(r));
|
||||
}
|
||||
|
||||
void RationalSlider::SetMinimum(const rational &d)
|
||||
void RationalSlider::set_minimum(const Rational &d)
|
||||
{
|
||||
SetMinimumInternal(QVariant::fromValue(d));
|
||||
set_minimum_internal(QVariant::fromValue(d));
|
||||
}
|
||||
|
||||
void RationalSlider::SetMaximum(const rational &d)
|
||||
void RationalSlider::set_maximum(const Rational &d)
|
||||
{
|
||||
SetMaximumInternal(QVariant::fromValue(d));
|
||||
set_maximum_internal(QVariant::fromValue(d));
|
||||
}
|
||||
|
||||
void RationalSlider::SetTimebase(const rational &timebase)
|
||||
void RationalSlider::set_timebase(const Rational &timebase)
|
||||
{
|
||||
timebase_ = timebase;
|
||||
|
||||
// Refresh label since we have a new timebase to generate a timecode with
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void RationalSlider::SetDisplayType(const RationalSlider::DisplayType &type)
|
||||
void RationalSlider::set_display_type(const RationalSlider::DisplayType &type)
|
||||
{
|
||||
display_type_ = type;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void RationalSlider::SetLockDisplayType(bool e)
|
||||
void RationalSlider::set_lock_display_type(bool e)
|
||||
{
|
||||
lock_display_type_ = e;
|
||||
}
|
||||
|
||||
bool RationalSlider::GetLockDisplayType()
|
||||
bool RationalSlider::get_lock_display_type()
|
||||
{
|
||||
return lock_display_type_;
|
||||
}
|
||||
|
||||
void RationalSlider::DisableDisplayType(RationalSlider::DisplayType type)
|
||||
void RationalSlider::disable_display_type(RationalSlider::DisplayType type)
|
||||
{
|
||||
disabled_.append(type);
|
||||
}
|
||||
|
||||
QString RationalSlider::ValueToString(const QVariant &v) const
|
||||
QString RationalSlider::value_to_string(const QVariant &v) const
|
||||
{
|
||||
rational r = v.value<rational>();
|
||||
Rational r = v.value<Rational>();
|
||||
|
||||
if (r.isNaN()) {
|
||||
return tr("NaN");
|
||||
} else {
|
||||
double val = r.toDouble() + GetOffset().value<rational>().toDouble();
|
||||
double val = r.to_double() + get_offset().value<Rational>().to_double();
|
||||
|
||||
switch (display_type_) {
|
||||
case kTime:
|
||||
case k_time:
|
||||
return QString::fromStdString(Timecode::time_to_timecode(
|
||||
r, timebase_, Core::instance()->GetTimecodeDisplay()));
|
||||
case kFloat:
|
||||
return FloatToString(val, GetDecimalPlaces(),
|
||||
GetAutoTrimDecimalPlaces());
|
||||
case kRational:
|
||||
return QString::fromStdString(v.value<rational>().toString());
|
||||
r, timebase_, Core::instance()->get_timecode_display()));
|
||||
case k_float:
|
||||
return float_to_string(val, get_decimal_places(),
|
||||
get_auto_trim_decimal_places());
|
||||
case k_rational:
|
||||
return QString::fromStdString(v.value<Rational>().to_string());
|
||||
}
|
||||
|
||||
return v.toString();
|
||||
}
|
||||
}
|
||||
|
||||
QVariant RationalSlider::StringToValue(const QString &s, bool *ok) const
|
||||
QVariant RationalSlider::string_to_value(const QString &s, bool *ok) const
|
||||
{
|
||||
rational r;
|
||||
Rational r;
|
||||
*ok = false;
|
||||
|
||||
switch (display_type_) {
|
||||
case kTime: {
|
||||
case k_time: {
|
||||
r = Timecode::timecode_to_time(s.toStdString(), timebase_,
|
||||
Core::instance()->GetTimecodeDisplay(),
|
||||
Core::instance()->get_timecode_display(),
|
||||
ok);
|
||||
break;
|
||||
}
|
||||
case kFloat: {
|
||||
case k_float: {
|
||||
// First, convert to a double
|
||||
double d = s.toDouble(ok);
|
||||
if (!(*ok)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// If double conversion succeeded, convert to a rational
|
||||
r = rational::fromDouble(d, ok);
|
||||
// If double conversion succeeded, convert to a Rational
|
||||
r = Rational::from_double(d, ok);
|
||||
break;
|
||||
}
|
||||
case kRational:
|
||||
r = rational::fromString(s.toStdString(), ok);
|
||||
case k_rational:
|
||||
r = Rational::from_string(s.toStdString(), ok);
|
||||
break;
|
||||
}
|
||||
|
||||
//return QVariant::fromValue(r - GetOffset().value<rational>());
|
||||
//return QVariant::fromValue(r - GetOffset().value<Rational>());
|
||||
return QVariant::fromValue(r);
|
||||
}
|
||||
|
||||
QVariant RationalSlider::AdjustDragDistanceInternal(const QVariant &start,
|
||||
QVariant RationalSlider::adjust_drag_distance_internal(const QVariant &start,
|
||||
const double &drag) const
|
||||
{
|
||||
// Assume we want smallest increment to be timebase or 1 frame
|
||||
return QVariant::fromValue(start.value<rational>() +
|
||||
rational::fromDouble(drag) * timebase_);
|
||||
return QVariant::fromValue(start.value<Rational>() +
|
||||
Rational::from_double(drag) * timebase_);
|
||||
}
|
||||
|
||||
void RationalSlider::ValueSignalEvent(const QVariant &v)
|
||||
void RationalSlider::value_signal_event(const QVariant &v)
|
||||
{
|
||||
emit ValueChanged(v.value<rational>());
|
||||
emit value_changed(v.value<Rational>());
|
||||
}
|
||||
|
||||
bool RationalSlider::ValueGreaterThan(const QVariant &lhs,
|
||||
bool RationalSlider::value_greater_than(const QVariant &lhs,
|
||||
const QVariant &rhs) const
|
||||
{
|
||||
return lhs.value<rational>() > rhs.value<rational>();
|
||||
return lhs.value<Rational>() > rhs.value<Rational>();
|
||||
}
|
||||
|
||||
bool RationalSlider::ValueLessThan(const QVariant &lhs,
|
||||
bool RationalSlider::value_less_than(const QVariant &lhs,
|
||||
const QVariant &rhs) const
|
||||
{
|
||||
return lhs.value<rational>() < rhs.value<rational>();
|
||||
return lhs.value<Rational>() < rhs.value<Rational>();
|
||||
}
|
||||
|
||||
void RationalSlider::ShowDisplayTypeMenu()
|
||||
void RationalSlider::show_display_type_menu()
|
||||
{
|
||||
Menu m(this);
|
||||
|
||||
if (!GetLockDisplayType()) {
|
||||
if (!disabled_.contains(kFloat)) {
|
||||
if (!get_lock_display_type()) {
|
||||
if (!disabled_.contains(k_float)) {
|
||||
QAction *float_action = m.addAction(tr("Float"));
|
||||
float_action->setData(kFloat);
|
||||
float_action->setData(k_float);
|
||||
connect(float_action, &QAction::triggered, this,
|
||||
&RationalSlider::SetDisplayTypeFromMenu);
|
||||
&RationalSlider::set_display_type_from_menu);
|
||||
}
|
||||
|
||||
if (!disabled_.contains(kRational)) {
|
||||
if (!disabled_.contains(k_rational)) {
|
||||
QAction *rational_action = m.addAction(tr("Rational"));
|
||||
rational_action->setData(kRational);
|
||||
rational_action->setData(k_rational);
|
||||
connect(rational_action, &QAction::triggered, this,
|
||||
&RationalSlider::SetDisplayTypeFromMenu);
|
||||
&RationalSlider::set_display_type_from_menu);
|
||||
}
|
||||
|
||||
if (!disabled_.contains(kTime)) {
|
||||
if (!disabled_.contains(k_time)) {
|
||||
QAction *time_action = m.addAction(tr("Time"));
|
||||
time_action->setData(kTime);
|
||||
time_action->setData(k_time);
|
||||
connect(time_action, &QAction::triggered, this,
|
||||
&RationalSlider::SetDisplayTypeFromMenu);
|
||||
&RationalSlider::set_display_type_from_menu);
|
||||
}
|
||||
}
|
||||
|
||||
if (display_type_ == kTime) {
|
||||
if (display_type_ == k_time) {
|
||||
if (!m.actions().isEmpty()) {
|
||||
m.addSeparator();
|
||||
}
|
||||
MenuShared::instance()->AddItemsForTimeRulerMenu(&m);
|
||||
MenuShared::instance()->AboutToShowTimeRulerActions(timebase_);
|
||||
MenuShared::instance()->add_items_for_time_ruler_menu(&m);
|
||||
MenuShared::instance()->about_to_show_time_ruler_actions(timebase_);
|
||||
}
|
||||
|
||||
if (!m.actions().isEmpty()) {
|
||||
m.exec(QCursor::pos());
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
}
|
||||
|
||||
void RationalSlider::SetDisplayTypeFromMenu()
|
||||
void RationalSlider::set_display_type_from_menu()
|
||||
{
|
||||
QAction *action = static_cast<QAction *>(sender());
|
||||
|
||||
DisplayType type = static_cast<DisplayType>(action->data().toInt());
|
||||
|
||||
SetDisplayType(type);
|
||||
set_display_type(type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef RATIONALSLIDER_H
|
||||
#define RATIONALSLIDER_H
|
||||
#ifndef OAK_RATIONALSLIDER_H
|
||||
#define OAK_RATIONALSLIDER_H
|
||||
|
||||
#include <olive/core/core.h>
|
||||
#include <QMouseEvent>
|
||||
@@ -33,7 +33,7 @@ namespace olive
|
||||
using namespace core;
|
||||
|
||||
/**
|
||||
* @brief A olive::rational based slider
|
||||
* @brief A olive::Rational based slider
|
||||
*
|
||||
* A slider that can display rationals as either timecode (drop or non-drop), a timestamp (frames),
|
||||
* or a float (seconds).
|
||||
@@ -44,90 +44,90 @@ public:
|
||||
/**
|
||||
* @brief enum containing the possibly display types
|
||||
*/
|
||||
enum DisplayType { kTime, kFloat, kRational };
|
||||
enum DisplayType { k_time, k_float, k_rational };
|
||||
|
||||
RationalSlider(QWidget *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Returns the sliders value as a rational
|
||||
* @brief Returns the sliders value as a Rational
|
||||
*/
|
||||
rational GetValue();
|
||||
Rational get_value();
|
||||
|
||||
/**
|
||||
* @brief Sets the sliders default value
|
||||
*/
|
||||
void SetDefaultValue(const rational &r);
|
||||
void SetDefaultValue(const Rational &r);
|
||||
|
||||
/**
|
||||
* @brief Sets the sliders minimum value
|
||||
*/
|
||||
void SetMinimum(const rational &d);
|
||||
void set_minimum(const Rational &d);
|
||||
|
||||
/**
|
||||
* @brief Sets the sliders maximum value
|
||||
*/
|
||||
void SetMaximum(const rational &d);
|
||||
void set_maximum(const Rational &d);
|
||||
|
||||
/**
|
||||
* @brief Sets the display type of the slider
|
||||
*/
|
||||
void SetDisplayType(const DisplayType &type);
|
||||
void set_display_type(const DisplayType &type);
|
||||
|
||||
/**
|
||||
* @brief Set whether the user can change the display type or not
|
||||
*/
|
||||
void SetLockDisplayType(bool e);
|
||||
void set_lock_display_type(bool e);
|
||||
|
||||
/**
|
||||
* @brief Get whether the user can change the display type or not
|
||||
*/
|
||||
bool GetLockDisplayType();
|
||||
bool get_lock_display_type();
|
||||
|
||||
/**
|
||||
* @brief Hide display type in menu
|
||||
*/
|
||||
void DisableDisplayType(DisplayType type);
|
||||
void disable_display_type(DisplayType type);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Sets the sliders timebase which is also the minimum increment of the slider
|
||||
*/
|
||||
void SetTimebase(const rational &timebase);
|
||||
void set_timebase(const Rational &timebase);
|
||||
|
||||
/**
|
||||
* @brief Sets the sliders value
|
||||
*/
|
||||
void SetValue(const rational &d);
|
||||
void set_value(const Rational &d);
|
||||
|
||||
protected:
|
||||
virtual QString ValueToString(const QVariant &v) const override;
|
||||
virtual QString value_to_string(const QVariant &v) const override;
|
||||
|
||||
virtual QVariant StringToValue(const QString &s, bool *ok) const override;
|
||||
virtual QVariant string_to_value(const QString &s, bool *ok) const override;
|
||||
|
||||
virtual QVariant
|
||||
AdjustDragDistanceInternal(const QVariant &start,
|
||||
adjust_drag_distance_internal(const QVariant &start,
|
||||
const double &drag) const override;
|
||||
|
||||
virtual void ValueSignalEvent(const QVariant &v) override;
|
||||
virtual void value_signal_event(const QVariant &v) override;
|
||||
|
||||
virtual bool ValueGreaterThan(const QVariant &lhs,
|
||||
virtual bool value_greater_than(const QVariant &lhs,
|
||||
const QVariant &rhs) const override;
|
||||
|
||||
virtual bool ValueLessThan(const QVariant &lhs,
|
||||
virtual bool value_less_than(const QVariant &lhs,
|
||||
const QVariant &rhs) const override;
|
||||
|
||||
signals:
|
||||
void ValueChanged(rational);
|
||||
void value_changed(Rational);
|
||||
|
||||
private slots:
|
||||
void ShowDisplayTypeMenu();
|
||||
void show_display_type_menu();
|
||||
|
||||
void SetDisplayTypeFromMenu();
|
||||
void set_display_type_from_menu();
|
||||
|
||||
private:
|
||||
DisplayType display_type_;
|
||||
|
||||
rational timebase_;
|
||||
Rational timebase_;
|
||||
|
||||
bool lock_display_type_;
|
||||
|
||||
@@ -136,4 +136,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // RATIONALSLIDER_H
|
||||
#endif // OAK_RATIONALSLIDER_H
|
||||
|
||||
@@ -29,42 +29,42 @@ namespace olive
|
||||
StringSlider::StringSlider(QWidget *parent)
|
||||
: super(parent)
|
||||
{
|
||||
SetValue(QString());
|
||||
set_value(QString());
|
||||
|
||||
connect(label(), &SliderLabel::LabelReleased, this,
|
||||
&SliderBase::ShowEditor);
|
||||
connect(label(), &SliderLabel::label_released, this,
|
||||
&SliderBase::show_editor);
|
||||
}
|
||||
|
||||
QString StringSlider::GetValue() const
|
||||
QString StringSlider::get_value() const
|
||||
{
|
||||
return GetValueInternal().toString();
|
||||
return get_value_internal().toString();
|
||||
}
|
||||
|
||||
void StringSlider::SetValue(const QString &v)
|
||||
void StringSlider::set_value(const QString &v)
|
||||
{
|
||||
SetValueInternal(v);
|
||||
set_value_internal(v);
|
||||
}
|
||||
|
||||
void StringSlider::SetDefaultValue(const QString &v)
|
||||
{
|
||||
super::SetDefaultValue(v);
|
||||
super::set_default_value(v);
|
||||
}
|
||||
|
||||
QString StringSlider::ValueToString(const QVariant &v) const
|
||||
QString StringSlider::value_to_string(const QVariant &v) const
|
||||
{
|
||||
QString vstr = v.toString();
|
||||
return (vstr.isEmpty()) ? tr("(none)") : vstr;
|
||||
}
|
||||
|
||||
QVariant StringSlider::StringToValue(const QString &s, bool *ok) const
|
||||
QVariant StringSlider::string_to_value(const QString &s, bool *ok) const
|
||||
{
|
||||
*ok = true;
|
||||
return s;
|
||||
}
|
||||
|
||||
void StringSlider::ValueSignalEvent(const QVariant &value)
|
||||
void StringSlider::value_signal_event(const QVariant &value)
|
||||
{
|
||||
emit ValueChanged(value.toString());
|
||||
emit value_changed(value.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef STRINGSLIDER_H
|
||||
#define STRINGSLIDER_H
|
||||
#ifndef OAK_STRINGSLIDER_H
|
||||
#define OAK_STRINGSLIDER_H
|
||||
|
||||
#include "base/sliderbase.h"
|
||||
|
||||
@@ -34,23 +34,23 @@ public:
|
||||
|
||||
void SetDragMultiplier(const double &d) = delete;
|
||||
|
||||
QString GetValue() const;
|
||||
QString get_value() const;
|
||||
|
||||
void SetValue(const QString &v);
|
||||
void set_value(const QString &v);
|
||||
|
||||
void SetDefaultValue(const QString &v);
|
||||
|
||||
signals:
|
||||
void ValueChanged(const QString &str);
|
||||
void value_changed(const QString &str);
|
||||
|
||||
protected:
|
||||
virtual QString ValueToString(const QVariant &value) const override;
|
||||
virtual QString value_to_string(const QVariant &value) const override;
|
||||
|
||||
virtual QVariant StringToValue(const QString &s, bool *ok) const override;
|
||||
virtual QVariant string_to_value(const QString &s, bool *ok) const override;
|
||||
|
||||
virtual void ValueSignalEvent(const QVariant &value) override;
|
||||
virtual void value_signal_event(const QVariant &value) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // STRINGSLIDER_H
|
||||
#endif // OAK_STRINGSLIDER_H
|
||||
|
||||
Reference in New Issue
Block a user