refactor: cut engine-to-UI include violations ahead of the liboakengine split

- slider DisplayType enums sink to node/sliderdisplaytype.h (canonical
  engine home); FloatSlider/RationalSlider alias them for compatibility
- DropWithoutSequenceBehavior enum sinks to common/dropworkflowbehavior.h
- Config errors now go through a registered ErrorHandler hook instead of
  QMessageBox with a MainWindow parent; the style default no longer
  depends on the UI style manager
- MainWindowLayoutInfo moves to node/project/serializer/ and its panel
  dependency is reduced to a plain std::map alias (PanelLayoutInfo),
  breaking the engine -> PanelWidget -> KDDockWidgets chain
- ProjectImportErrorDialog moves from task/ to dialog/projectimport/
- remove confirmed-redundant UI includes and give project.h/import.h/
  project.cpp the direct includes they were borrowing transitively
- project.h includes folder/sequence headers directly (it used both
  types in its own API all along)
This commit is contained in:
2026-07-20 00:52:12 +08:00
parent 98f2f3e224
commit 03d4087124
71 changed files with 321 additions and 163 deletions
-1
View File
@@ -25,7 +25,6 @@
#include <pa_jack.h>
#endif
#include <QApplication>
#include "config/config.h"
-1
View File
@@ -24,7 +24,6 @@
#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QMessageBox>
#include "common/oiioutils.h"
#include "render/renderer.h"
-1
View File
@@ -27,7 +27,6 @@
#include <QDateTime>
#include <QDebug>
#include <QDir>
#include <QMessageBox>
#include <QProcess>
#include "crashpadutils.h"
+43
View File
@@ -0,0 +1,43 @@
/***
Oak - Non-Linear Video Editor
Copyright (C) 2026 Oak 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 OAK_DROPWORKFLOWBEHAVIOR_H
#define OAK_DROPWORKFLOWBEHAVIOR_H
namespace olive
{
/**
* @brief Behavior when media is dropped onto a timeline without a sequence
*
* Shared by the config defaults (engine layer) and the timeline import
* tool (UI layer). Enumerator order matches the previous
* ImportTool::DropWithoutSequenceBehavior.
*/
enum DropWithoutSequenceBehavior {
k_dws_ask,
k_dws_auto,
k_dws_manual,
k_dws_disable
};
}
#endif // OAK_DROPWORKFLOWBEHAVIOR_H
+25 -19
View File
@@ -24,26 +24,39 @@
#include <QCoreApplication>
#include <QDebug>
#include <QDir>
#include <QMessageBox>
#include <QStandardPaths>
#include <QXmlStreamWriter>
#include "codec/exportformat.h"
#include "common/autoscroll.h"
#include "common/dropworkflowbehavior.h"
#include "common/filefunctions.h"
#include "common/xmlutils.h"
#include "core.h"
#include "timeline/timelinecommon.h"
#include "ui/colorcoding.h"
#include "ui/style/style.h"
#include "widget/timelinewidget/tool/import.h"
#include "window/mainwindow/mainwindow.h"
namespace olive
{
Config Config::current_config;
Config::ErrorHandler Config::error_handler_ = nullptr;
void Config::set_error_handler(ErrorHandler handler)
{
error_handler_ = handler;
}
void Config::report_error(const QString &title, const QString &message)
{
if (error_handler_) {
error_handler_(title, message);
} else {
qWarning() << title << "-" << message;
}
}
Config::Config()
{
set_defaults();
@@ -69,8 +82,10 @@ Config &Config::current()
void Config::set_defaults()
{
config_map_.clear();
// Default style name; the style itself lives in the UI layer
// (ui/style), which owns the definitive list
set_entry_internal(QStringLiteral("Style"), NodeValue::k_text,
StyleManager::k_default_style);
QStringLiteral("olive-dark"));
set_entry_internal(QStringLiteral("TimecodeDisplay"), NodeValue::k_int,
Timecode::k_timecode_drop_frame);
set_entry_internal(QStringLiteral("DefaultStillLength"), NodeValue::k_rational,
@@ -124,7 +139,7 @@ void Config::set_defaults()
set_entry_internal(QStringLiteral("RectifiedWaveforms"), NodeValue::k_boolean,
true);
set_entry_internal(QStringLiteral("DropWithoutSequenceBehavior"),
NodeValue::k_int, ImportTool::k_dws_ask);
NodeValue::k_int, k_dws_ask);
set_entry_internal(QStringLiteral("Loop"), NodeValue::k_boolean, false);
set_entry_internal(QStringLiteral("SplitClipsCopyNodes"), NodeValue::k_boolean,
true);
@@ -356,20 +371,13 @@ void Config::load()
}
if (reader.hasError()) {
// Config::Load() is called before Core (and therefore the main window)
// is constructed, so we cannot use Core::instance()->main_window() as
// the message box parent. Passing nullptr creates a top-level dialog.
QWidget *parent = Core::instance() ? Core::instance()->main_window() :
nullptr;
QMessageBox::critical(
parent,
report_error(
QCoreApplication::translate("Config", "Error loading settings"),
QCoreApplication::translate(
"Config",
"Failed to load application settings. This session will "
"use defaults.\n\n%1")
.arg(reader.errorString()),
QMessageBox::Ok);
.arg(reader.errorString()));
current_config.set_defaults();
}
@@ -385,14 +393,12 @@ void Config::save()
QFile config_file(temp_filename);
if (!config_file.open(QFile::WriteOnly)) {
QMessageBox::critical(
Core::instance()->main_window(),
report_error(
QCoreApplication::translate("Config", "Error saving settings"),
QCoreApplication::translate(
"Config",
"Failed to save application settings. The application "
"may lack write permissions for this location."),
QMessageBox::Ok);
"may lack write permissions for this location."));
return;
}
+16
View File
@@ -44,6 +44,18 @@ public:
static void save();
/**
* @brief Handler for configuration errors that should be shown to the user
*
* The engine layer cannot show dialogs itself. The UI registers a
* handler (e.g. QMessageBox-based) at startup; without one, errors go
* to the log instead.
*/
using ErrorHandler = void (*)(const QString &title,
const QString &message);
static void set_error_handler(ErrorHandler handler);
QVariant operator[](const QString &) const;
QVariant &operator[](const QString &);
@@ -65,6 +77,10 @@ private:
static Config current_config;
static ErrorHandler error_handler_;
static void report_error(const QString &title, const QString &message);
static QString get_config_file_path();
};
+1 -1
View File
@@ -71,7 +71,7 @@
#include "task/project/saveotio/saveotio.h"
#endif
#include "task/project/import/import.h"
#include "task/project/import/importerrordialog.h"
#include "dialog/projectimport/projectimporterrordialog.h"
#include "task/project/load/load.h"
#include "task/project/save/save.h"
#include "task/taskmanager.h"
-1
View File
@@ -34,7 +34,6 @@
#include "task/task.h"
#include "tool/tool.h"
#include "undo/undostack.h"
#include "widget/projectexplorer/projectviewmodel.h"
namespace olive
{
+1
View File
@@ -30,6 +30,7 @@ if (OpenTimelineIO_FOUND)
endif ()
add_subdirectory(preferences)
add_subdirectory(progress)
add_subdirectory(projectimport)
add_subdirectory(proxy)
add_subdirectory(projectproperties)
add_subdirectory(rendercancel)
+1 -1
View File
@@ -49,7 +49,7 @@ ImageSection::ImageSection(QWidget *parent)
frame_slider_ = new RationalSlider();
frame_slider_->set_minimum(0);
frame_slider_->set_value(0);
frame_slider_->set_display_type(RationalSlider::k_time);
frame_slider_->set_display_type(slider::k_time);
connect(frame_slider_, &RationalSlider::value_changed, this,
&ImageSection::time_changed);
layout->addWidget(frame_slider_, row, 1);
@@ -47,7 +47,7 @@ KeyframePropertiesDialog::KeyframePropertiesDialog(
layout->addWidget(new QLabel("Time:"), row, 0);
time_slider_ = new RationalSlider();
time_slider_->set_display_type(RationalSlider::k_time);
time_slider_->set_display_type(slider::k_time);
time_slider_->set_timebase(timebase_);
layout->addWidget(time_slider_, row, 1);
@@ -65,10 +65,10 @@ MarkerPropertiesDialog::MarkerPropertiesDialog(
if (markers.size() == 1) {
in_slider_->set_value(markers.front()->time().in());
in_slider_->set_display_type(RationalSlider::k_time);
in_slider_->set_display_type(slider::k_time);
in_slider_->set_timebase(timebase);
out_slider_->set_value(markers.front()->time().out());
out_slider_->set_display_type(RationalSlider::k_time);
out_slider_->set_display_type(slider::k_time);
out_slider_->set_timebase(timebase);
} else {
// Markers cannot be on the same time, so we disable setting time if multiple markers are selected
+23
View File
@@ -0,0 +1,23 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2022 Olive Team
# Modifications Copyright (C) 2026 Oak 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}
dialog/projectimport/projectimporterrordialog.cpp
dialog/projectimport/projectimporterrordialog.h
PARENT_SCOPE
)
@@ -19,7 +19,7 @@
***/
#include "importerrordialog.h"
#include "projectimporterrordialog.h"
#include <QDialogButtonBox>
#include <QLabel>
@@ -57,7 +57,7 @@ SpeedDurationDialog::SpeedDurationDialog(const QVector<ClipBlock *> &clips,
speed_layout->addWidget(new QLabel(tr("Speed:")), row, 0);
speed_slider_ = new FloatSlider();
speed_slider_->set_display_type(FloatSlider::k_percentage);
speed_slider_->set_display_type(slider::k_percentage);
connect(speed_slider_, &FloatSlider::value_changed, this,
&SpeedDurationDialog::speed_changed);
speed_layout->addWidget(speed_slider_, row, 1);
@@ -68,7 +68,7 @@ SpeedDurationDialog::SpeedDurationDialog(const QVector<ClipBlock *> &clips,
dur_slider_ = new RationalSlider();
dur_slider_->set_timebase(timebase);
dur_slider_->set_display_type(RationalSlider::k_time);
dur_slider_->set_display_type(slider::k_time);
connect(dur_slider_, &RationalSlider::value_changed, this,
&SpeedDurationDialog::duration_changed);
speed_layout->addWidget(dur_slider_, row, 1);
+10
View File
@@ -341,6 +341,16 @@ int main(int argc, char *argv[])
a.reset(new QCoreApplication(argc, argv));
}
// Configuration errors are reported through a UI handler so the engine
// layer (config) never has to know about dialogs
olive::Config::set_error_handler(
[](const QString &title, const QString &message) {
QWidget *parent =
olive::Core::instance() ? olive::Core::instance()->main_window() :
nullptr;
QMessageBox::critical(parent, title, message, QMessageBox::Ok);
});
olive::Config::load();
const QString graphics_backend =
olive::Config::current()[QStringLiteral("GraphicsBackend")]
+2 -2
View File
@@ -21,7 +21,7 @@
#include "pan.h"
#include "widget/slider/floatslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -40,7 +40,7 @@ PanNode::PanNode()
set_input_property(k_panning_input, QStringLiteral("min"), -1.0);
set_input_property(k_panning_input, QStringLiteral("max"), 1.0);
set_input_property(k_panning_input, QStringLiteral("view"),
FloatSlider::k_percentage);
slider::k_percentage);
set_flag(k_audio_effect);
set_effect_input(k_samples_input);
+2 -2
View File
@@ -21,7 +21,7 @@
#include "volume.h"
#include "widget/slider/floatslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -39,7 +39,7 @@ VolumeNode::VolumeNode()
add_input(k_volume_input, NodeValue::k_float, 1.0);
set_input_property(k_volume_input, QStringLiteral("min"), 0.0);
set_input_property(k_volume_input, QStringLiteral("view"),
FloatSlider::k_decibel);
slider::k_decibel);
set_flag(k_audio_effect);
set_effect_input(k_samples_input);
+2 -2
View File
@@ -24,7 +24,7 @@
#include <QDebug>
#include "node/inputdragger.h"
#include "widget/slider/rationalslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -44,7 +44,7 @@ Block::Block()
set_input_property(k_length_input, QStringLiteral("min"),
QVariant::fromValue(Rational(0, 1)));
set_input_property(k_length_input, QStringLiteral("view"),
RationalSlider::k_time);
slider::k_time);
set_input_property(k_length_input, QStringLiteral("viewlock"), true);
set_input_flag(k_enabled_input, k_input_flag_not_connectable);
+4 -4
View File
@@ -26,8 +26,8 @@
#include "node/output/track/track.h"
#include "node/output/viewer/viewer.h"
#include "node/project/sequence/sequence.h"
#include "widget/slider/floatslider.h"
#include "widget/slider/rationalslider.h"
#include "node/sliderdisplaytype.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -51,13 +51,13 @@ ClipBlock::ClipBlock()
add_input(k_media_in_input, NodeValue::k_rational,
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable));
set_input_property(k_media_in_input, QStringLiteral("view"),
RationalSlider::k_time);
slider::k_time);
set_input_property(k_media_in_input, QStringLiteral("viewlock"), true);
add_input(k_speed_input, NodeValue::k_float, 1.0,
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable));
set_input_property(k_speed_input, QStringLiteral("view"),
FloatSlider::k_percentage);
slider::k_percentage);
set_input_property(k_speed_input, QStringLiteral("min"), 0.0);
add_input(k_reverse_input, NodeValue::k_boolean, false,
+2 -2
View File
@@ -23,7 +23,7 @@
#include "node/block/clip/clip.h"
#include "node/output/track/track.h"
#include "widget/slider/rationalslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -51,7 +51,7 @@ TransitionBlock::TransitionBlock()
add_input(k_center_input, NodeValue::k_rational,
InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable));
set_input_property(k_center_input, QStringLiteral("view"),
RationalSlider::k_time);
slider::k_time);
set_input_property(k_center_input, QStringLiteral("viewlock"), true);
set_flag(k_dont_show_in_param_view, false);
@@ -26,7 +26,7 @@
#include "common/ocioutils.h"
#include "node/project.h"
#include "render/colorprocessor.h"
#include "widget/slider/floatslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -71,7 +71,7 @@ OCIOGradingTransformLinearNode::OCIOGradingTransformLinearNode()
add_input(k_saturation_input, NodeValue::k_float, 1.0);
set_input_property(k_saturation_input, QStringLiteral("view"),
FloatSlider::k_percentage);
slider::k_percentage);
set_input_property(k_saturation_input, QStringLiteral("min"), 0.0);
add_input(k_pivot_input, NodeValue::k_float,
@@ -26,7 +26,7 @@
#include "common/ocioutils.h"
#include "node/project.h"
#include "render/colorprocessor.h"
#include "widget/slider/floatslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -71,7 +71,7 @@ OCIOGradingTransformLogNode::OCIOGradingTransformLogNode()
add_input(k_saturation_input, NodeValue::k_float, 1.0);
set_input_property(k_saturation_input, QStringLiteral("view"),
FloatSlider::k_percentage);
slider::k_percentage);
set_input_property(k_saturation_input, QStringLiteral("min"), 0.0);
add_input(k_pivot_input, NodeValue::k_float,
+1 -1
View File
@@ -20,10 +20,10 @@
#include "ociolut.h"
#include <QApplication>
#include <QFileInfo>
#include <QMetaObject>
#include <QApplication>
#include "core.h"
#include "node/color/colormanager/colormanager.h"
@@ -24,7 +24,7 @@
#include <QVector3D>
#include "node/project.h"
#include "widget/slider/floatslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -66,9 +66,9 @@ ThreeWayColorNode::ThreeWayColorNode()
set_input_property(k_shadows_amount_input, min, 0.0);
set_input_property(k_midtones_amount_input, min, 0.0);
set_input_property(k_highlights_amount_input, min, 0.0);
set_input_property(k_shadows_amount_input, view, FloatSlider::k_percentage);
set_input_property(k_midtones_amount_input, view, FloatSlider::k_percentage);
set_input_property(k_highlights_amount_input, view, FloatSlider::k_percentage);
set_input_property(k_shadows_amount_input, view, slider::k_percentage);
set_input_property(k_midtones_amount_input, view, slider::k_percentage);
set_input_property(k_highlights_amount_input, view, slider::k_percentage);
set_effect_input(k_texture_input);
set_flag(k_video_effect);
+2 -2
View File
@@ -25,7 +25,7 @@
#include "common/filefunctions.h"
#include "render/job/shaderjob.h"
#include "render/texture.h"
#include "widget/slider/floatslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -47,7 +47,7 @@ WhiteBalanceNode::WhiteBalanceNode()
set_input_property(k_temperature_input, QStringLiteral("min"), 1000.0);
set_input_property(k_temperature_input, QStringLiteral("max"), 40000.0);
set_input_property(k_temperature_input, QStringLiteral("view"),
FloatSlider::k_normal);
slider::k_normal);
add_input(k_tint_input, NodeValue::k_float, 0.0);
set_input_property(k_tint_input, QStringLiteral("min"), -1.0);
@@ -23,7 +23,6 @@
#include "common/lerp.h"
#include "core.h"
#include "widget/slider/floatslider.h"
namespace olive
{
+2 -2
View File
@@ -23,7 +23,7 @@
#include "common/util.h"
#include "core.h"
#include "widget/slider/floatslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -183,7 +183,7 @@ void CropDistortNode::create_crop_side_input(const QString &id)
add_input(id, NodeValue::k_float, 0.0);
set_input_property(id, QStringLiteral("min"), 0.0);
set_input_property(id, QStringLiteral("max"), 1.0);
set_input_property(id, QStringLiteral("view"), FloatSlider::k_percentage);
set_input_property(id, QStringLiteral("view"), slider::k_percentage);
}
}
+2 -2
View File
@@ -21,7 +21,7 @@
#include "tiledistortnode.h"
#include "widget/slider/floatslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -43,7 +43,7 @@ TileDistortNode::TileDistortNode()
add_input(k_scale_input, NodeValue::k_float, 0.5);
set_input_property(k_scale_input, QStringLiteral("min"), 0);
set_input_property(k_scale_input, QStringLiteral("view"),
FloatSlider::k_percentage);
slider::k_percentage);
add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0));
+2 -2
View File
@@ -19,7 +19,7 @@
#include "opacityeffect.h"
#include "node/math/math/math.h"
#include "widget/slider/floatslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -43,7 +43,7 @@ OpacityEffect::OpacityEffect()
add_input(k_value_input, NodeValue::k_float, 1.0);
set_input_property(k_value_input, QStringLiteral("view"),
FloatSlider::k_percentage);
slider::k_percentage);
set_input_property(k_value_input, QStringLiteral("min"), 0.0);
set_input_property(k_value_input, QStringLiteral("max"), 1.0);
@@ -21,7 +21,7 @@
#include "dropshadowfilter.h"
#include "widget/slider/floatslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -54,7 +54,7 @@ DropShadowFilter::DropShadowFilter()
add_input(k_opacity_input, NodeValue::k_float, 1.0);
set_input_property(k_opacity_input, QStringLiteral("min"), 0.0);
set_input_property(k_opacity_input, QStringLiteral("view"),
FloatSlider::k_percentage);
slider::k_percentage);
add_input(k_fast_input, NodeValue::k_boolean, false);
+2 -2
View File
@@ -21,7 +21,7 @@
#include "stroke.h"
#include "widget/slider/floatslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -47,7 +47,7 @@ StrokeFilterNode::StrokeFilterNode()
add_input(k_opacity_input, NodeValue::k_float, 1.0f);
set_input_property(k_opacity_input, QStringLiteral("view"),
FloatSlider::k_percentage);
slider::k_percentage);
set_input_property(k_opacity_input, QStringLiteral("min"), 0.0f);
set_input_property(k_opacity_input, QStringLiteral("max"), 1.0f);
+2 -2
View File
@@ -24,7 +24,7 @@
#include <QMatrix4x4>
#include <QVector2D>
#include "widget/slider/floatslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -47,7 +47,7 @@ MatrixGenerator::MatrixGenerator()
add_input(k_scale_input, NodeValue::k_vec2, QVector2D(1.0f, 1.0f));
set_input_property(k_scale_input, QStringLiteral("min"), QVector2D(0, 0));
set_input_property(k_scale_input, QStringLiteral("view"),
FloatSlider::k_percentage);
slider::k_percentage);
set_input_property(k_scale_input, QStringLiteral("disable1"), true);
add_input(k_uniform_scale_input, NodeValue::k_boolean, true,
+2 -2
View File
@@ -21,7 +21,7 @@
#include "noise.h"
#include "widget/slider/floatslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -40,7 +40,7 @@ NoiseGeneratorNode::NoiseGeneratorNode()
add_input(k_strength_input, NodeValue::k_float, 0.2);
set_input_property(k_strength_input, QStringLiteral("view"),
FloatSlider::k_percentage);
slider::k_percentage);
set_input_property(k_strength_input, QStringLiteral("min"), 0);
add_input(k_color_input, NodeValue::k_boolean, false);
-1
View File
@@ -21,7 +21,6 @@
#include "track.h"
#include <QApplication>
#include <QDebug>
#include <QFontMetrics>
+2 -2
View File
@@ -28,14 +28,14 @@
#include "common/qtutils.h"
#include "common/xmlutils.h"
#include "core.h"
#include "dialog/progress/progress.h"
#include "node/color/ociobase/ociobase.h"
#include "node/factory.h"
#include "node/group/group.h"
#include "node/project/folder/folder.h"
#include "node/serializeddata.h"
#include "pluginSupport/olivehost.h"
#include "ofxhPluginCache.h"
#include "render/diskmanager.h"
#include "window/mainwindow/mainwindow.h"
namespace olive
{
+2 -1
View File
@@ -27,9 +27,10 @@
#include <QUuid>
#include "node/output/viewer/viewer.h"
#include "node/project/folder/folder.h"
#include "node/project/footage/footage.h"
#include "node/project/sequence/sequence.h"
#include "node/color/colormanager/colormanager.h"
#include "window/mainwindow/mainwindowlayoutinfo.h"
namespace olive
{
-1
View File
@@ -23,7 +23,6 @@
#include <QThread>
#include "panel/timeline/timeline.h"
#include "ui/icons/icons.h"
#include "timeline/timelineundogeneral.h"
@@ -33,6 +33,9 @@ set(OLIVE_SOURCES
node/project/serializer/serializer230220.h
node/project/serializer/mainwindowlayoutinfo.cpp
node/project/serializer/mainwindowlayoutinfo.h
node/project/serializer/typeserializer.cpp
node/project/serializer/typeserializer.h
@@ -63,7 +63,7 @@ void MainWindowLayoutInfo::to_xml(QXmlStreamWriter *writer) const
writer->writeAttribute(QStringLiteral("id"), it->first);
const PanelWidget::Info &info = it->second;
const PanelLayoutInfo &info = it->second;
for (auto jt = info.cbegin(); jt != info.cend(); jt++) {
writer->writeStartElement(QStringLiteral("option"));
@@ -158,7 +158,7 @@ MainWindowLayoutInfo::from_xml(QXmlStreamReader *reader,
}
if (!id.isEmpty()) {
PanelWidget::Info i;
PanelLayoutInfo i;
while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("option")) {
@@ -211,7 +211,7 @@ void MainWindowLayoutInfo::add_viewer(ViewerOutput *viewer)
}
void MainWindowLayoutInfo::set_panel_data(const QString &id,
const PanelWidget::Info &data)
const PanelLayoutInfo &data)
{
panel_data_[id] = data;
}
@@ -219,7 +219,7 @@ void MainWindowLayoutInfo::set_panel_data(const QString &id,
void MainWindowLayoutInfo::move_panel_data(const QString &old,
const QString &now)
{
PanelWidget::Info tmp = panel_data_.at(old);
PanelLayoutInfo tmp = panel_data_.at(old);
panel_data_.erase(old);
panel_data_[now] = tmp;
}
@@ -19,13 +19,22 @@
#ifndef OAK_MAINWINDOWLAYOUTINFO_H
#define OAK_MAINWINDOWLAYOUTINFO_H
#include <map>
#include "node/project/folder/folder.h"
#include "node/project/sequence/sequence.h"
#include "panel/panel.h"
namespace olive
{
/**
* @brief Per-panel layout data (key/value pairs)
*
* Identical to PanelWidget::Info in the UI layer; defined here so the
* engine-side layout data structure does not depend on widget headers.
*/
using PanelLayoutInfo = std::map<QString, QString>;
class MainWindowLayoutInfo {
public:
MainWindowLayoutInfo() = default;
@@ -41,7 +50,7 @@ public:
void add_viewer(ViewerOutput *viewer);
void set_panel_data(const QString &id, const PanelWidget::Info &data);
void set_panel_data(const QString &id, const PanelLayoutInfo &data);
void move_panel_data(const QString &old, const QString &now);
@@ -62,7 +71,7 @@ public:
return open_viewers_;
}
const std::map<QString, PanelWidget::Info> &panel_data() const
const std::map<QString, PanelLayoutInfo> &panel_data() const
{
return panel_data_;
}
@@ -81,7 +90,7 @@ private:
std::vector<ViewerOutput *> open_viewers_;
std::map<QString, PanelWidget::Info> panel_data_;
std::map<QString, PanelLayoutInfo> panel_data_;
static const unsigned int k_version = 1;
};
+1
View File
@@ -26,6 +26,7 @@
#include "common/define.h"
#include "node/project.h"
#include "node/project/serializer/mainwindowlayoutinfo.h"
#include "typeserializer.h"
namespace olive
+47
View File
@@ -0,0 +1,47 @@
/***
Oak - Non-Linear Video Editor
Copyright (C) 2026 Oak 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 OAK_SLIDERDISPLAYTYPE_H
#define OAK_SLIDERDISPLAYTYPE_H
namespace olive
{
/**
* @brief Slider display type enums shared by nodes and widgets
*
* Nodes reference these enums in their input properties ("view"); the
* slider widgets in app/widget/slider use the same values to render. The
* definitions live in the engine layer so nodes do not depend on widget
* headers. Enumerator order is ABI/feature compatible with the previous
* FloatSlider::DisplayType and RationalSlider::DisplayType.
*/
namespace slider
{
enum FloatDisplayType { k_normal, k_decibel, k_percentage };
enum RationalDisplayType { k_time, k_float, k_rational };
} // namespace slider
} // namespace olive
#endif // OAK_SLIDERDISPLAYTYPE_H
+2 -2
View File
@@ -21,7 +21,7 @@
#include "timeoffsetnode.h"
#include "widget/slider/rationalslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -35,7 +35,7 @@ TimeOffsetNode::TimeOffsetNode()
{
add_input(k_time_input, NodeValue::k_rational, QVariant::fromValue(Rational(0)),
InputFlags(k_input_flag_not_connectable));
set_input_property(k_time_input, QStringLiteral("view"), RationalSlider::k_time);
set_input_property(k_time_input, QStringLiteral("view"), slider::k_time);
set_input_property(k_time_input, QStringLiteral("viewlock"), true);
add_input(k_input_input, NodeValue::k_none,
+2 -2
View File
@@ -21,7 +21,7 @@
#include "timeremap.h"
#include "widget/slider/rationalslider.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -35,7 +35,7 @@ TimeRemapNode::TimeRemapNode()
{
add_input(k_time_input, NodeValue::k_rational, QVariant::fromValue(Rational(0)),
InputFlags(k_input_flag_not_connectable));
set_input_property(k_time_input, QStringLiteral("view"), RationalSlider::k_time);
set_input_property(k_time_input, QStringLiteral("view"), slider::k_time);
set_input_property(k_time_input, QStringLiteral("viewlock"), true);
add_input(k_input_input, NodeValue::k_none,
-1
View File
@@ -21,7 +21,6 @@
#include "previewautocacher.h"
#include <QApplication>
#include <QPointer>
#include <QtConcurrent/QtConcurrent>
-2
View File
@@ -21,7 +21,6 @@
#include "rendermanager.h"
#include <QApplication>
#include <QMatrix4x4>
#include <QThread>
@@ -35,7 +34,6 @@
#include "renderworkerpool.h"
#include "task/conform/conform.h"
#include "task/taskmanager.h"
#include "window/mainwindow/mainwindow.h"
namespace olive
{
-1
View File
@@ -26,7 +26,6 @@
#include "config/config.h"
#include "colorprocessorcache.h"
#include "dialog/rendercancel/rendercancel.h"
#include "node/output/viewer/viewer.h"
#include "node/project.h"
#include "node/traverser.h"
-2
View File
@@ -18,7 +18,5 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES}
task/project/import/import.h
task/project/import/import.cpp
task/project/import/importerrordialog.h
task/project/import/importerrordialog.cpp
PARENT_SCOPE
)
+2 -1
View File
@@ -26,8 +26,9 @@
#include <QUndoCommand>
#include "codec/decoder.h"
#include "node/project/footage/footage.h"
#include "node/project/folder/folder.h"
#include "task/task.h"
#include "widget/projectexplorer/projectviewmodel.h"
namespace olive
{
+1 -1
View File
@@ -23,7 +23,7 @@
#define OAK_PROJECTLOADMANAGER_H
#include "loadbasetask.h"
#include "window/mainwindow/mainwindowlayoutinfo.h"
#include "node/project/serializer/mainwindowlayoutinfo.h"
namespace olive
{
+1
View File
@@ -23,6 +23,7 @@
#define OAK_PROJECTLOADBASETASK_H
#include "node/project.h"
#include "node/project/serializer/mainwindowlayoutinfo.h"
#include "task/task.h"
namespace olive
+1
View File
@@ -23,6 +23,7 @@
#define OAK_PROJECTSAVEMANAGER_H
#include "node/project.h"
#include "node/project/serializer/mainwindowlayoutinfo.h"
#include "task/task.h"
namespace olive
+1 -1
View File
@@ -664,7 +664,7 @@ CurveView::get_float_display_type_from_keyframe(NodeKeyframe *key)
}
// Fallback to normal
return FloatSlider::k_normal;
return slider::k_normal;
}
double CurveView::get_offset_from_keyframe(NodeKeyframe *key)
@@ -57,7 +57,7 @@ PlaybackControls::PlaybackControls(QWidget *parent)
lower_left_layout->setContentsMargins(0, 0, 0, 0);
cur_tc_lbl_ = new RationalSlider();
cur_tc_lbl_->set_display_type(RationalSlider::k_time);
cur_tc_lbl_->set_display_type(slider::k_time);
cur_tc_lbl_->set_minimum(0);
connect(cur_tc_lbl_, &RationalSlider::value_changed, this,
&PlaybackControls::time_changed);
+14 -14
View File
@@ -33,7 +33,7 @@ namespace olive
FloatSlider::FloatSlider(QWidget *parent)
: super(parent)
, display_type_(k_normal)
, display_type_(slider::k_normal)
{
set_value(0.0);
}
@@ -68,13 +68,13 @@ void FloatSlider::set_display_type(const FloatSlider::DisplayType &type)
display_type_ = type;
switch (display_type_) {
case k_normal:
case slider::k_normal:
clear_format();
break;
case k_decibel:
case slider::k_decibel:
set_format(tr("%1 dB"));
break;
case k_percentage:
case slider::k_percentage:
set_format(tr("%1%"));
break;
}
@@ -83,12 +83,12 @@ void FloatSlider::set_display_type(const FloatSlider::DisplayType &type)
double FloatSlider::transform_value_to_display(double val, DisplayType display)
{
switch (display) {
case k_normal:
case slider::k_normal:
break;
case k_decibel:
case slider::k_decibel:
val = Decibel::from_linear(val);
break;
case k_percentage:
case slider::k_percentage:
val *= 100.0;
break;
}
@@ -99,12 +99,12 @@ double FloatSlider::transform_value_to_display(double val, DisplayType display)
double FloatSlider::transform_display_to_value(double val, DisplayType display)
{
switch (display) {
case k_normal:
case slider::k_normal:
break;
case k_decibel:
case slider::k_decibel:
val = Decibel::to_linear(val);
break;
case k_percentage:
case slider::k_percentage:
val *= 0.01;
break;
}
@@ -117,7 +117,7 @@ QString FloatSlider::value_to_string(double val, FloatSlider::DisplayType displa
bool autotrim_decimal_places)
{
// Return negative infinity for zero volume
if (display == k_decibel && qIsNull(val)) {
if (display == slider::k_decibel && qIsNull(val)) {
return tr("\xE2\x88\x9E");
}
@@ -154,17 +154,17 @@ QVariant FloatSlider::adjust_drag_distance_internal(const QVariant &start,
const double &drag) const
{
switch (display_type_) {
case k_normal:
case slider::k_normal:
// No change here
break;
case k_decibel: {
case slider::k_decibel: {
double current_db = Decibel::from_linear(start.toDouble());
current_db += drag;
double adjusted_linear = Decibel::to_linear(current_db);
return adjusted_linear;
}
case k_percentage:
case slider::k_percentage:
return super::adjust_drag_distance_internal(start, drag * 0.01);
}
+5 -1
View File
@@ -23,6 +23,7 @@
#define OAK_FLOATSLIDER_H
#include "base/decimalsliderbase.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -32,7 +33,10 @@ class FloatSlider : public DecimalSliderBase {
public:
FloatSlider(QWidget *parent = nullptr);
enum DisplayType { k_normal, k_decibel, k_percentage };
// The canonical definition lives in the engine layer
// (node/sliderdisplaytype.h); this alias keeps existing call sites
// source-compatible. Use slider::k_normal etc. for the enumerators.
using DisplayType = slider::FloatDisplayType;
double get_value() const;
+14 -14
View File
@@ -39,7 +39,7 @@ RationalSlider::RationalSlider(QWidget *parent)
connect(SliderBase::label(), &SliderLabel::customContextMenuRequested, this,
&RationalSlider::show_display_type_menu);
set_display_type(k_float);
set_display_type(slider::k_float);
set_value(Rational(0, 0));
}
@@ -109,13 +109,13 @@ QString RationalSlider::value_to_string(const QVariant &v) const
double val = r.to_double() + get_offset().value<Rational>().to_double();
switch (display_type_) {
case k_time:
case slider::k_time:
return QString::fromStdString(Timecode::time_to_timecode(
r, timebase_, Core::instance()->get_timecode_display()));
case k_float:
case slider::k_float:
return float_to_string(val, get_decimal_places(),
get_auto_trim_decimal_places());
case k_rational:
case slider::k_rational:
return QString::fromStdString(v.value<Rational>().to_string());
}
@@ -129,13 +129,13 @@ QVariant RationalSlider::string_to_value(const QString &s, bool *ok) const
*ok = false;
switch (display_type_) {
case k_time: {
case slider::k_time: {
r = Timecode::timecode_to_time(s.toStdString(), timebase_,
Core::instance()->get_timecode_display(),
ok);
break;
}
case k_float: {
case slider::k_float: {
// First, convert to a double
double d = s.toDouble(ok);
if (!(*ok)) {
@@ -146,7 +146,7 @@ QVariant RationalSlider::string_to_value(const QString &s, bool *ok) const
r = Rational::from_double(d, ok);
break;
}
case k_rational:
case slider::k_rational:
r = Rational::from_string(s.toStdString(), ok);
break;
}
@@ -185,29 +185,29 @@ void RationalSlider::show_display_type_menu()
Menu m(this);
if (!get_lock_display_type()) {
if (!disabled_.contains(k_float)) {
if (!disabled_.contains(slider::k_float)) {
QAction *float_action = m.addAction(tr("Float"));
float_action->setData(k_float);
float_action->setData(slider::k_float);
connect(float_action, &QAction::triggered, this,
&RationalSlider::set_display_type_from_menu);
}
if (!disabled_.contains(k_rational)) {
if (!disabled_.contains(slider::k_rational)) {
QAction *rational_action = m.addAction(tr("Rational"));
rational_action->setData(k_rational);
rational_action->setData(slider::k_rational);
connect(rational_action, &QAction::triggered, this,
&RationalSlider::set_display_type_from_menu);
}
if (!disabled_.contains(k_time)) {
if (!disabled_.contains(slider::k_time)) {
QAction *time_action = m.addAction(tr("Time"));
time_action->setData(k_time);
time_action->setData(slider::k_time);
connect(time_action, &QAction::triggered, this,
&RationalSlider::set_display_type_from_menu);
}
}
if (display_type_ == k_time) {
if (display_type_ == slider::k_time) {
if (!m.actions().isEmpty()) {
m.addSeparator();
}
+6 -1
View File
@@ -26,6 +26,7 @@
#include <QMouseEvent>
#include "base/decimalsliderbase.h"
#include "node/sliderdisplaytype.h"
namespace olive
{
@@ -43,8 +44,12 @@ class RationalSlider : public DecimalSliderBase {
public:
/**
* @brief enum containing the possibly display types
*
* The canonical definition lives in the engine layer
* (node/sliderdisplaytype.h); this alias keeps existing call sites
* source-compatible. Use slider::k_time etc. for the enumerators.
*/
enum DisplayType { k_time, k_float, k_rational };
using DisplayType = slider::RationalDisplayType;
RationalSlider(QWidget *parent = nullptr);
+1 -1
View File
@@ -161,7 +161,7 @@ TimelineWidget::TimelineWidget(QWidget *parent)
timecode_label_ = new RationalSlider();
timecode_label_->set_alignment(Qt::AlignCenter);
timecode_label_->set_display_type(RationalSlider::k_time);
timecode_label_->set_display_type(slider::k_time);
timecode_label_->setVisible(false);
timecode_label_->set_minimum(0);
ruler_and_time_layout->addWidget(timecode_label_);
+7 -6
View File
@@ -22,6 +22,7 @@
#ifndef OAK_IMPORTTIMELINETOOL_H
#define OAK_IMPORTTIMELINETOOL_H
#include "common/dropworkflowbehavior.h"
#include "tool.h"
namespace olive
@@ -46,12 +47,12 @@ public:
bool insert, MultiUndoCommand *command, int track_offset = 0,
bool jump_to_end = false);
enum DropWithoutSequenceBehavior {
k_dws_ask,
k_dws_auto,
k_dws_manual,
k_dws_disable
};
// The canonical definition lives in the engine layer
// (common/dropworkflowbehavior.h); this alias keeps existing call
// sites source-compatible. Use olive::k_dws_ask etc. for the
// enumerators (visible unqualified inside namespace olive).
using DropWithoutSequenceBehavior =
olive::DropWithoutSequenceBehavior;
private:
void footage_to_ghosts(Rational ghost_start,
-2
View File
@@ -22,8 +22,6 @@ set(OLIVE_SOURCES
window/mainwindow/mainstatusbar.cpp
window/mainwindow/mainwindow.h
window/mainwindow/mainwindow.cpp
window/mainwindow/mainwindowlayoutinfo.h
window/mainwindow/mainwindowlayoutinfo.cpp
window/mainwindow/mainwindowundo.h
window/mainwindow/mainwindowundo.cpp
PARENT_SCOPE
+1 -1
View File
@@ -25,7 +25,7 @@
#include <kddockwidgets/Config.h>
#include <kddockwidgets/MainWindow.h>
#include "mainwindowlayoutinfo.h"
#include "node/project/serializer/mainwindowlayoutinfo.h"
#include "node/project.h"
#include "panel/multicam/multicampanel.h"
#include "panel/panelmanager.h"
+1 -1
View File
@@ -24,7 +24,7 @@
#include "widget/menu/menushared.h"
#include "window/mainwindow/mainstatusbar.h"
#include "window/mainwindow/mainwindow.h"
#include "window/mainwindow/mainwindowlayoutinfo.h"
#include "node/project/serializer/mainwindowlayoutinfo.h"
using namespace olive;
+2 -2
View File
@@ -227,7 +227,7 @@ TEST(PanNode, InputDefaults)
EXPECT_EQ(int(pan.get_input_property(olive::PanNode::k_panning_input,
QStringLiteral("view"))
.toInt()),
int(olive::FloatSlider::k_percentage));
int(olive::slider::k_percentage));
}
TEST(PanNode, RetranslateSetsInputNames)
@@ -489,7 +489,7 @@ TEST(VolumeNode, InputDefaults)
EXPECT_EQ(int(volume.get_input_property(olive::VolumeNode::k_volume_input,
QStringLiteral("view"))
.toInt()),
int(olive::FloatSlider::k_decibel));
int(olive::slider::k_decibel));
}
TEST(VolumeNode, RetranslateSetsInputNames)
+2 -2
View File
@@ -533,7 +533,7 @@ TEST(CropDistortNode, InputDefinitionsAndDefaults)
EXPECT_DOUBLE_EQ(
node.get_input_property(side, QStringLiteral("max")).toDouble(), 1.0);
EXPECT_EQ(node.get_input_property(side, QStringLiteral("view")).toInt(),
int(olive::FloatSlider::k_percentage));
int(olive::slider::k_percentage));
}
EXPECT_DOUBLE_EQ(
@@ -1521,7 +1521,7 @@ TEST(TileDistortNode, InputDefaults)
EXPECT_EQ(node.get_input_property(olive::TileDistortNode::k_scale_input,
QStringLiteral("view"))
.toInt(),
int(olive::FloatSlider::k_percentage));
int(olive::slider::k_percentage));
EXPECT_EQ(node.get_standard_value(olive::TileDistortNode::k_position_input)
.value<QVector2D>(),
+3 -3
View File
@@ -103,7 +103,7 @@ TEST(OpacityEffect, InputDefinitionsAndDefaults)
EXPECT_EQ(node.get_input_property(olive::OpacityEffect::k_value_input,
QStringLiteral("view"))
.toInt(),
int(olive::FloatSlider::k_percentage));
int(olive::slider::k_percentage));
}
TEST(OpacityEffect, Identity)
@@ -616,7 +616,7 @@ TEST(DropShadowFilter, InputDefinitionsAndDefaults)
EXPECT_EQ(node.get_input_property(olive::DropShadowFilter::k_opacity_input,
QStringLiteral("view"))
.toInt(),
int(olive::FloatSlider::k_percentage));
int(olive::slider::k_percentage));
EXPECT_FALSE(
node.get_standard_value(olive::DropShadowFilter::k_fast_input).toBool());
}
@@ -933,7 +933,7 @@ TEST(StrokeFilterNode, InputDefinitionsAndDefaults)
EXPECT_EQ(node.get_input_property(olive::StrokeFilterNode::k_opacity_input,
QStringLiteral("view"))
.toInt(),
int(olive::FloatSlider::k_percentage));
int(olive::slider::k_percentage));
EXPECT_FALSE(
node.get_standard_value(olive::StrokeFilterNode::k_inner_input).toBool());
}
+2 -2
View File
@@ -171,7 +171,7 @@ TEST(MatrixGenerator, InputDefaultsAndProperties)
EXPECT_EQ(node->get_input_property(olive::MatrixGenerator::k_scale_input,
QStringLiteral("view"))
.toInt(),
int(olive::FloatSlider::k_percentage));
int(olive::slider::k_percentage));
EXPECT_EQ(node->get_input_property(olive::MatrixGenerator::k_scale_input,
QStringLiteral("min"))
.value<QVector2D>(),
@@ -676,7 +676,7 @@ TEST(NoiseGenerator, InputDefaults)
EXPECT_EQ(node->get_input_property(olive::NoiseGeneratorNode::k_strength_input,
QStringLiteral("view"))
.toInt(),
int(olive::FloatSlider::k_percentage));
int(olive::slider::k_percentage));
EXPECT_EQ(int(node->get_input_data_type(olive::NoiseGeneratorNode::k_color_input)),
int(olive::NodeValue::k_boolean));
+1 -1
View File
@@ -19,7 +19,7 @@
#include "node/project/serializer/serializer.h"
#include "render/diskmanager.h"
#include "task/project/import/import.h"
#include "task/project/import/importerrordialog.h"
#include "dialog/projectimport/projectimporterrordialog.h"
#include "task/project/load/load.h"
#include "undo/undocommand.h"
+16 -16
View File
@@ -105,43 +105,43 @@ TEST(WidgetSlider, FloatRangeChangeClampsExistingValue)
TEST(WidgetSlider, FloatDisplayTransformRoundTrips)
{
EXPECT_DOUBLE_EQ(
olive::FloatSlider::transform_value_to_display(0.5, olive::FloatSlider::k_percentage),
olive::FloatSlider::transform_value_to_display(0.5, olive::slider::k_percentage),
50.0);
EXPECT_DOUBLE_EQ(
olive::FloatSlider::transform_display_to_value(50.0, olive::FloatSlider::k_percentage),
olive::FloatSlider::transform_display_to_value(50.0, olive::slider::k_percentage),
0.5);
EXPECT_DOUBLE_EQ(
olive::FloatSlider::transform_value_to_display(1.0, olive::FloatSlider::k_decibel),
olive::FloatSlider::transform_value_to_display(1.0, olive::slider::k_decibel),
0.0);
EXPECT_NEAR(
olive::FloatSlider::transform_value_to_display(0.5, olive::FloatSlider::k_decibel),
olive::FloatSlider::transform_value_to_display(0.5, olive::slider::k_decibel),
-6.0206, 0.001);
EXPECT_NEAR(
olive::FloatSlider::transform_display_to_value(
olive::FloatSlider::transform_value_to_display(0.75, olive::FloatSlider::k_decibel),
olive::FloatSlider::k_decibel),
olive::FloatSlider::transform_value_to_display(0.75, olive::slider::k_decibel),
olive::slider::k_decibel),
0.75, 1e-12);
EXPECT_DOUBLE_EQ(
olive::FloatSlider::transform_value_to_display(3.5, olive::FloatSlider::k_normal),
olive::FloatSlider::transform_value_to_display(3.5, olive::slider::k_normal),
3.5);
EXPECT_DOUBLE_EQ(
olive::FloatSlider::transform_display_to_value(3.5, olive::FloatSlider::k_normal),
olive::FloatSlider::transform_display_to_value(3.5, olive::slider::k_normal),
3.5);
}
TEST(WidgetSlider, FloatStaticValueToStringRespectsDisplayType)
{
// Zero volume in decibel mode displays as an infinity symbol (U+221E)
EXPECT_EQ(olive::FloatSlider::value_to_string(0.0, olive::FloatSlider::k_decibel, 2,
EXPECT_EQ(olive::FloatSlider::value_to_string(0.0, olive::slider::k_decibel, 2,
false),
QString(QChar(0x221E)));
EXPECT_EQ(olive::FloatSlider::value_to_string(0.5, olive::FloatSlider::k_percentage,
EXPECT_EQ(olive::FloatSlider::value_to_string(0.5, olive::slider::k_percentage,
1, false),
QStringLiteral("50.0"));
EXPECT_EQ(olive::FloatSlider::value_to_string(1.234, olive::FloatSlider::k_normal,
EXPECT_EQ(olive::FloatSlider::value_to_string(1.234, olive::slider::k_normal,
2, false),
QStringLiteral("1.23"));
}
@@ -155,14 +155,14 @@ TEST(WidgetSlider, FloatLabelShowsFormattedValue)
s.set_value(0.5);
EXPECT_EQ(label->text(), QStringLiteral("0.50"));
s.set_display_type(olive::FloatSlider::k_percentage);
s.set_display_type(olive::slider::k_percentage);
EXPECT_EQ(label->text(), QStringLiteral("50.00%"));
s.set_format(QStringLiteral("%1 px"));
EXPECT_EQ(label->text(), QStringLiteral("50.00 px"));
s.clear_format();
s.set_display_type(olive::FloatSlider::k_normal);
s.set_display_type(olive::slider::k_normal);
EXPECT_EQ(label->text(), QStringLiteral("0.50"));
}
@@ -191,7 +191,7 @@ TEST(WidgetSlider, FloatStringToValueRejectsGarbage)
TEST(WidgetSlider, FloatStringToValueRespectsDisplayType)
{
ExposedFloatSlider s;
s.set_display_type(olive::FloatSlider::k_percentage);
s.set_display_type(olive::slider::k_percentage);
bool ok = false;
QVariant v = s.string_to_value_public(QStringLiteral("50"), &ok);
@@ -207,11 +207,11 @@ TEST(WidgetSlider, FloatDragDistanceRespectsDisplayType)
EXPECT_DOUBLE_EQ(s.adjust_drag_public(1.0, 2.5).toDouble(), 3.5);
// Percentage: drag is scaled by 1/100
s.set_display_type(olive::FloatSlider::k_percentage);
s.set_display_type(olive::slider::k_percentage);
EXPECT_DOUBLE_EQ(s.adjust_drag_public(0.5, 10.0).toDouble(), 0.6);
// Decibel: drag happens in dB space
s.set_display_type(olive::FloatSlider::k_decibel);
s.set_display_type(olive::slider::k_decibel);
const double expected =
olive::Decibel::to_linear(olive::Decibel::from_linear(1.0) + 6.0);
EXPECT_DOUBLE_EQ(s.adjust_drag_public(1.0, 6.0).toDouble(), expected);