diff --git a/app/audio/audiomanager.cpp b/app/audio/audiomanager.cpp index 99a1612b3..77bedcb6d 100644 --- a/app/audio/audiomanager.cpp +++ b/app/audio/audiomanager.cpp @@ -130,11 +130,11 @@ void AudioManager::SetOutputDevice(const QAudioDeviceInfo &info) } output_ = std::unique_ptr(new QAudioOutput(info, format, this)); - connect(output_.get(), SIGNAL(notify()), this, SLOT(OutputNotified())); + connect(output_.get(), &QAudioOutput::notify, this, &AudioManager::OutputNotified); } // Un-comment this to get debug information about what the audio output is doing - //connect(output_.get(), SIGNAL(stateChanged(QAudio::State)), this, SLOT(OutputStateChanged(QAudio::State))); + //connect(output_.get(), &QAudioOutput::stateChanged, this, &AudioManager::OutputStateChanged); } void AudioManager::SetOutputParams(const AudioRenderingParams ¶ms) @@ -169,12 +169,12 @@ AudioManager::AudioManager() : input_file_(nullptr), refreshing_devices_(false) { - connect(&refresh_thread_, SIGNAL(ListsReady()), this, SLOT(RefreshThreadDone())); + connect(&refresh_thread_, &AudioRefreshDevicesThread::ListsReady, this, &AudioManager::RefreshThreadDone); RefreshDevices(); - connect(&output_manager_, SIGNAL(HasSamples()), this, SLOT(OutputManagerHasSamples())); - connect(&output_manager_, SIGNAL(SentSamples(QVector)), this, SIGNAL(SentSamples(QVector))); + connect(&output_manager_, &AudioHybridDevice::HasSamples, this, &AudioManager::OutputManagerHasSamples); + connect(&output_manager_, &AudioHybridDevice::SentSamples, this, &AudioManager::SentSamples); output_manager_.SetEnableSendingSamples(true); output_manager_.open(AudioHybridDevice::ReadOnly); diff --git a/app/codec/decoder.h b/app/codec/decoder.h index 3bdc5492d..71d31b35d 100644 --- a/app/codec/decoder.h +++ b/app/codec/decoder.h @@ -45,8 +45,8 @@ using DecoderPtr = std::shared_ptr; * necessitate pre-emptively caching, indexing, or even fully transcoding media before using it which can be implemented * through the Analyze() function. * - * A decoder does NOT perform any pixel/sample format conversion. Frames should pass through the PixelFormatConverter - * (olive::pix_fmt_conv) to be utilized in the rest of the rendering pipeline. + * A decoder does NOT perform any pixel/sample format conversion. Frames should pass through the PixelService + * to be utilized in the rest of the rendering pipeline. */ class Decoder : public QObject { diff --git a/app/codec/ffmpeg/ffmpegcommon.cpp b/app/codec/ffmpeg/ffmpegcommon.cpp index 82337eb78..2d2063dba 100644 --- a/app/codec/ffmpeg/ffmpegcommon.cpp +++ b/app/codec/ffmpeg/ffmpegcommon.cpp @@ -66,36 +66,36 @@ AVSampleFormat FFmpegCommon::GetFFmpegSampleFormat(const SampleFormat &smp_fmt) return AV_SAMPLE_FMT_NONE; } -AVPixelFormat FFmpegCommon::GetFFmpegPixelFormat(const olive::PixelFormat &pix_fmt) +AVPixelFormat FFmpegCommon::GetFFmpegPixelFormat(const PixelFormat::Format &pix_fmt) { switch (pix_fmt) { - case olive::PIX_FMT_RGBA8: + case PixelFormat::PIX_FMT_RGBA8: return AV_PIX_FMT_RGBA; - case olive::PIX_FMT_RGBA16U: + case PixelFormat::PIX_FMT_RGBA16U: return AV_PIX_FMT_RGBA64; - case olive::PIX_FMT_RGBA16F: - case olive::PIX_FMT_RGBA32F: - case olive::PIX_FMT_INVALID: - case olive::PIX_FMT_COUNT: + case PixelFormat::PIX_FMT_RGBA16F: + case PixelFormat::PIX_FMT_RGBA32F: + case PixelFormat::PIX_FMT_INVALID: + case PixelFormat::PIX_FMT_COUNT: break; } return AV_PIX_FMT_NONE; } -olive::PixelFormat FFmpegCommon::GetCompatiblePixelFormat(const olive::PixelFormat &pix_fmt) +PixelFormat::Format FFmpegCommon::GetCompatiblePixelFormat(const PixelFormat::Format &pix_fmt) { switch (pix_fmt) { - case olive::PIX_FMT_RGBA8: - return olive::PIX_FMT_RGBA8; - case olive::PIX_FMT_RGBA16U: - case olive::PIX_FMT_RGBA16F: - case olive::PIX_FMT_RGBA32F: - return olive::PIX_FMT_RGBA16U; - case olive::PIX_FMT_INVALID: - case olive::PIX_FMT_COUNT: + case PixelFormat::PIX_FMT_RGBA8: + return PixelFormat::PIX_FMT_RGBA8; + case PixelFormat::PIX_FMT_RGBA16U: + case PixelFormat::PIX_FMT_RGBA16F: + case PixelFormat::PIX_FMT_RGBA32F: + return PixelFormat::PIX_FMT_RGBA16U; + case PixelFormat::PIX_FMT_INVALID: + case PixelFormat::PIX_FMT_COUNT: break; } - return olive::PIX_FMT_INVALID; + return PixelFormat::PIX_FMT_INVALID; } diff --git a/app/codec/ffmpeg/ffmpegcommon.h b/app/codec/ffmpeg/ffmpegcommon.h index f04d87c8a..c322e55b9 100644 --- a/app/codec/ffmpeg/ffmpegcommon.h +++ b/app/codec/ffmpeg/ffmpegcommon.h @@ -18,12 +18,12 @@ public: /** * @brief Returns a native pixel format that can be used to convert from a native frame to an AVFrame with minimal data loss */ - static olive::PixelFormat GetCompatiblePixelFormat(const olive::PixelFormat& pix_fmt); + static PixelFormat::Format GetCompatiblePixelFormat(const PixelFormat::Format& pix_fmt); /** * @brief Returns an FFmpeg pixel format for a given native pixel format */ - static AVPixelFormat GetFFmpegPixelFormat(const olive::PixelFormat& pix_fmt); + static AVPixelFormat GetFFmpegPixelFormat(const PixelFormat::Format& pix_fmt); /** * @brief Returns a native sample format type for a given AVSampleFormat diff --git a/app/codec/ffmpeg/ffmpegdecoder.cpp b/app/codec/ffmpeg/ffmpegdecoder.cpp index 98b5edda2..56ad361ce 100644 --- a/app/codec/ffmpeg/ffmpegdecoder.cpp +++ b/app/codec/ffmpeg/ffmpegdecoder.cpp @@ -141,10 +141,10 @@ bool FFmpegDecoder::Open() // Note that FFmpeg doesn't support float formats switch (ideal_pix_fmt) { case AV_PIX_FMT_RGBA: - output_fmt_ = olive::PIX_FMT_RGBA8; + output_fmt_ = PixelFormat::PIX_FMT_RGBA8; break; case AV_PIX_FMT_RGBA64: - output_fmt_ = olive::PIX_FMT_RGBA16U; + output_fmt_ = PixelFormat::PIX_FMT_RGBA16U; break; default: // We should never get here, but if we do there's nothing we can do with this format @@ -224,13 +224,13 @@ FramePtr FFmpegDecoder::RetrieveVideo(const rational &timecode) FramePtr frame_container = Frame::Create(); frame_container->set_width(frame->width); frame_container->set_height(frame->height); - frame_container->set_format(static_cast(output_fmt_)); + frame_container->set_format(static_cast(output_fmt_)); frame_container->set_timestamp(Timecode::timestamp_to_time(target_ts, avstream_->time_base)); frame_container->allocate(); // Convert pixel format/linesize if necessary uint8_t* dst_data = reinterpret_cast(frame_container->data()); - int dst_linesize = frame_container->width() * PixelService::BytesPerPixel(static_cast(output_fmt_)); + int dst_linesize = frame_container->width() * PixelService::BytesPerPixel(static_cast(output_fmt_)); // Perform pixel conversion sws_scale(scale_ctx_, diff --git a/app/codec/ffmpeg/ffmpegencoder.cpp b/app/codec/ffmpeg/ffmpegencoder.cpp index d3c06bc09..4cf57c366 100644 --- a/app/codec/ffmpeg/ffmpegencoder.cpp +++ b/app/codec/ffmpeg/ffmpegencoder.cpp @@ -115,7 +115,7 @@ bool FFmpegEncoder::OpenInternal() } // This is the format we will expect frames received in Write() to be in - olive::PixelFormat native_pixel_fmt = params().video_params().format(); + PixelFormat::Format native_pixel_fmt = params().video_params().format(); // This is the format we will need to convert the frame to for swscale to understand it video_conversion_fmt_ = FFmpegCommon::GetCompatiblePixelFormat(native_pixel_fmt); diff --git a/app/codec/ffmpeg/ffmpegencoder.h b/app/codec/ffmpeg/ffmpegencoder.h index 095c8880f..1f26643c1 100644 --- a/app/codec/ffmpeg/ffmpegencoder.h +++ b/app/codec/ffmpeg/ffmpegencoder.h @@ -56,7 +56,7 @@ private: AVStream* video_stream_; AVCodecContext* video_codec_ctx_; SwsContext* video_scale_ctx_; - olive::PixelFormat video_conversion_fmt_; + PixelFormat::Format video_conversion_fmt_; AVStream* audio_stream_; AVCodecContext* audio_codec_ctx_; diff --git a/app/codec/frame.cpp b/app/codec/frame.cpp index b4928b04f..0d25dad35 100644 --- a/app/codec/frame.cpp +++ b/app/codec/frame.cpp @@ -28,7 +28,7 @@ Frame::Frame() : width_(0), height_(0), - format_(olive::PIX_FMT_INVALID), + format_(PixelFormat::PIX_FMT_INVALID), sample_count_(0), timestamp_(0) { @@ -89,12 +89,12 @@ void Frame::set_native_timestamp(const int64_t ×tamp) native_timestamp_ = timestamp; }*/ -const olive::PixelFormat &Frame::format() +const PixelFormat::Format &Frame::format() { return format_; } -void Frame::set_format(const olive::PixelFormat &format) +void Frame::set_format(const PixelFormat::Format &format) { format_ = format; } @@ -128,7 +128,7 @@ void Frame::allocate() { // Assume this frame is intended to be a video frame if (width_ > 0 && height_ > 0) { - data_.resize(PixelService::GetBufferSize(static_cast(format_), width_, height_)); + data_.resize(PixelService::GetBufferSize(static_cast(format_), width_, height_)); } else if (sample_count_ > 0) { data_.resize(audio_params_.samples_to_bytes(sample_count_)); } diff --git a/app/codec/frame.h b/app/codec/frame.h index a3f03f882..e173a8cf9 100644 --- a/app/codec/frame.h +++ b/app/codec/frame.h @@ -82,8 +82,8 @@ public: * * Currently this will either be an olive::PixelFormat (video) or an olive::SampleFormat (audio). */ - const olive::PixelFormat& format(); - void set_format(const olive::PixelFormat& format); + const PixelFormat::Format& format(); + void set_format(const PixelFormat::Format& format); /** * @brief Returns a copy of the data in this frame as a QByteArray @@ -128,7 +128,7 @@ private: int height_; - olive::PixelFormat format_; + PixelFormat::Format format_; AudioRenderingParams audio_params_; diff --git a/app/codec/oiio/oiiodecoder.cpp b/app/codec/oiio/oiiodecoder.cpp index f42e5562d..c26c99a8d 100644 --- a/app/codec/oiio/oiiodecoder.cpp +++ b/app/codec/oiio/oiiodecoder.cpp @@ -84,13 +84,13 @@ bool OIIODecoder::Open() // Weirdly, switch statement doesn't work correctly here if (spec.format == OIIO::TypeDesc::UINT8) { - pix_fmt_ = olive::PIX_FMT_RGBA8; + pix_fmt_ = PixelFormat::PIX_FMT_RGBA8; } else if (spec.format == OIIO::TypeDesc::UINT16) { - pix_fmt_ = olive::PIX_FMT_RGBA16U; + pix_fmt_ = PixelFormat::PIX_FMT_RGBA16U; } else if (spec.format == OIIO::TypeDesc::HALF) { - pix_fmt_ = olive::PIX_FMT_RGBA16F; + pix_fmt_ = PixelFormat::PIX_FMT_RGBA16F; } else if (spec.format == OIIO::TypeDesc::FLOAT) { - pix_fmt_ = olive::PIX_FMT_RGBA32F; + pix_fmt_ = PixelFormat::PIX_FMT_RGBA32F; } else { qWarning() << "Failed to convert OIIO::ImageDesc to native pixel format"; return false; @@ -100,7 +100,7 @@ bool OIIODecoder::Open() is_rgba_ = (spec.nchannels == kRGBAChannels); - pix_fmt_info_ = PixelService::GetPixelFormatInfo(static_cast(pix_fmt_)); + pix_fmt_info_ = PixelService::GetPixelFormatInfo(static_cast(pix_fmt_)); return true; } diff --git a/app/codec/oiio/oiiodecoder.h b/app/codec/oiio/oiiodecoder.h index 07dd9c2fa..ae99bf78e 100644 --- a/app/codec/oiio/oiiodecoder.h +++ b/app/codec/oiio/oiiodecoder.h @@ -52,9 +52,9 @@ private: int height_; - olive::PixelFormat pix_fmt_; + PixelFormat::Format pix_fmt_; - PixelFormatInfo pix_fmt_info_; + PixelFormat::Info pix_fmt_info_; bool is_rgba_; diff --git a/app/common/CMakeLists.txt b/app/common/CMakeLists.txt index 37f01e99e..584d9f8be 100644 --- a/app/common/CMakeLists.txt +++ b/app/common/CMakeLists.txt @@ -18,22 +18,25 @@ set(OLIVE_SOURCES ${OLIVE_SOURCES} common/channellayout.h common/clamp.h + common/constructors.h common/debug.h common/debug.cpp + common/define.h common/filefunctions.h common/filefunctions.cpp common/flipmodifiers.h common/flipmodifiers.cpp common/lerp.h + common/qtversionabstraction.h + common/qtversionabstraction.cpp common/range.h common/rational.h common/rational.cpp - common/qtversionabstraction.h - common/qtversionabstraction.cpp common/threadedobject.h common/threadedobject.cpp common/timecodefunctions.h common/timecodefunctions.cpp + common/timelinecommon.h common/timerange.h common/timerange.cpp PARENT_SCOPE diff --git a/app/common/decibel.cpp b/app/common/decibel.cpp deleted file mode 100644 index c93efbc95..000000000 --- a/app/common/decibel.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "decibel.h" - -#include - -double amplitude_to_db(double amplitude) { - return (20.0*(qLn(amplitude)/qLn(10.0))); -} - -double db_to_amplitude(double db) { - return qPow(M_E, (db*qLn(10.0))/20.0); -} diff --git a/app/common/decibel.h b/app/common/decibel.h deleted file mode 100644 index 2c7bdedfe..000000000 --- a/app/common/decibel.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef DECIBEL_H -#define DECIBEL_H - -/** - * @brief Converts an amplitude into a value in decibels - * - * Converts a 0.0-1.0 amplitude into an infinity-0.0 decibel value - */ -double amplitude_to_db(double amplitude); - -/** - * @brief Converts decibels into an amplitude value - * - * Converts an infinity-0.0 decibel value into a 0.0-1.0 amplitude - */ -double db_to_amplitude(double db); - -#endif // DECIBEL_H diff --git a/app/common/define.h b/app/common/define.h index 967a5e878..2bed051f9 100644 --- a/app/common/define.h +++ b/app/common/define.h @@ -24,4 +24,13 @@ const int kRGBChannels = 3; const int kRGBAChannels = 4; +/// The minimum size an icon in ProjectExplorer can be +const int kProjectIconSizeMinimum = 16; + +/// The maximum size an icon in ProjectExplorer can be +const int kProjectIconSizeMaximum = 256; + +/// The default size an icon in ProjectExplorer can be +const int kProjectIconSizeDefault = 64; + #endif // OLIVECOMMONDEFINE_H diff --git a/app/common/timecodefunctions.cpp b/app/common/timecodefunctions.cpp index 1717ee0b8..8d1947f8f 100644 --- a/app/common/timecodefunctions.cpp +++ b/app/common/timecodefunctions.cpp @@ -255,3 +255,8 @@ Timecode::Display Timecode::CurrentDisplay() { return static_cast(Config::Current()["TimecodeDisplay"].toInt()); } + +void Timecode::SetCurrentDisplay(Timecode::Display d) +{ + Config::Current()["TimecodeDisplay"] = d; +} diff --git a/app/common/timecodefunctions.h b/app/common/timecodefunctions.h index be26c63b7..a57be0f94 100644 --- a/app/common/timecodefunctions.h +++ b/app/common/timecodefunctions.h @@ -46,6 +46,7 @@ public: }; static Display CurrentDisplay(); + static void SetCurrentDisplay(Display d); /** * @brief Convert a timestamp (according to a rational timebase) to a user-friendly string representation diff --git a/app/common/timelinecommon.h b/app/common/timelinecommon.h index 01cce97d3..03762c3a0 100644 --- a/app/common/timelinecommon.h +++ b/app/common/timelinecommon.h @@ -1,20 +1,14 @@ #ifndef TIMELINECOMMON_H #define TIMELINECOMMON_H -namespace olive { - -namespace timeline { - -enum MovementMode { - kNone, - kMove, - kTrimIn, - kTrimOut +class Timeline { +public: + enum MovementMode { + kNone, + kMove, + kTrimIn, + kTrimOut + }; }; -} - -} - - #endif // TIMELINECOMMON_H diff --git a/app/config/config.cpp b/app/config/config.cpp index 8637106a9..b838fabbf 100644 --- a/app/config/config.cpp +++ b/app/config/config.cpp @@ -99,7 +99,7 @@ void Config::Load() } if (reader.hasError()) { - QMessageBox::critical(olive::core.main_window(), + QMessageBox::critical(Core::instance()->main_window(), QCoreApplication::translate("Config", "Error loading settings"), QCoreApplication::translate("Config", "Failed to load application settings. This session will " "use defaults."), @@ -115,7 +115,7 @@ void Config::Save() QFile config_file(GetConfigFilePath()); if (!config_file.open(QFile::WriteOnly)) { - QMessageBox::critical(olive::core.main_window(), + QMessageBox::critical(Core::instance()->main_window(), QCoreApplication::translate("Config", "Error saving settings"), QCoreApplication::translate("Config", "Failed to save application settings. The application " "may lack write permissions to this location."), diff --git a/app/core.cpp b/app/core.cpp index 3fe135d08..2abd63cf5 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -50,7 +50,7 @@ #include "widget/menu/menushared.h" #include "widget/taskview/taskviewitem.h" -Core olive::core; +Core Core::instance_; Core::Core() : main_window_(nullptr), @@ -60,6 +60,11 @@ Core::Core() : { } +Core *Core::instance() +{ + return &instance_; +} + void Core::Start() { // @@ -117,6 +122,8 @@ void Core::Stop() // Save Config //Config::Save(); + MenuShared::DestroyInstance(); + PanelManager::DestroyInstance(); AudioManager::DestroyInstance(); @@ -131,6 +138,11 @@ MainWindow *Core::main_window() return main_window_; } +UndoStack *Core::undo_stack() +{ + return &undo_stack_; +} + void Core::ImportFiles(const QStringList &urls, ProjectViewModel* model, Folder* parent) { if (urls.isEmpty()) { @@ -138,7 +150,7 @@ void Core::ImportFiles(const QStringList &urls, ProjectViewModel* model, Folder* return; } - olive::task_manager.AddTask(std::make_shared(model, parent, urls)); + TaskManager::instance()->AddTask(std::make_shared(model, parent, urls)); } const Tool::Item &Core::tool() @@ -272,7 +284,7 @@ void Core::CreateNewFolder() folder, new_folder); - olive::undo_stack.push(aic); + Core::instance()->undo_stack()->push(aic); // Trigger an automatic rename so users can enter the folder name active_project_panel->Edit(new_folder.get()); @@ -322,7 +334,7 @@ void Core::CreateNewSequence() new_sequence->add_default_nodes(); - olive::undo_stack.push(aic); + Core::instance()->undo_stack()->push(aic); Sequence::Open(new_sequence); } @@ -354,7 +366,7 @@ void Core::StartGUI(bool full_screen) StyleManager::SetStyle(StyleManager::DefaultStyle()); // Set up shared menus - olive::menu_shared.Initialize(); + MenuShared::CreateInstance(); // Since we're starting GUI mode, create a PanelFocusManager (auto-deletes with QObject) PanelManager::CreateInstance(); diff --git a/app/core.h b/app/core.h index 518b831df..05d54545a 100644 --- a/app/core.h +++ b/app/core.h @@ -30,6 +30,7 @@ #include "window/mainwindow/mainwindow.h" #include "task/task.h" #include "tool/tool.h" +#include "undo/undostack.h" /** * @brief The main central Olive application instance @@ -51,6 +52,13 @@ public: */ Core(); + /** + * @brief Core object accessible from anywhere in the code + * + * Use this to access Core functions. + */ + static Core* instance(); + /** * @brief Start Olive Core * @@ -74,6 +82,11 @@ public: */ MainWindow* main_window(); + /** + * @brief Retrieve UndoStack object + */ + UndoStack* undo_stack(); + /** * @brief Import a list of files * @@ -290,18 +303,19 @@ private: */ QTimer autorecovery_timer_; + /** + * @brief Application-wide undo stack instance + */ + UndoStack undo_stack_; + + /** + * @brief Static singleton core instance + */ + static Core instance_; + private slots: void SaveAutorecovery(); }; -namespace olive { -/** - * @brief Core object accessible from anywhere in the code - * - * Use this to access Core functions. - */ -extern Core core; -} - #endif // CORE_H diff --git a/app/dialog/export/export.cpp b/app/dialog/export/export.cpp index 1e6c7e58c..a1734332c 100644 --- a/app/dialog/export/export.cpp +++ b/app/dialog/export/export.cpp @@ -179,7 +179,7 @@ void ExportDialog::accept() dest_height); // FIXME: Hardcoded pixel format - VideoRenderingParams video_render_params(dest_width, dest_height, video_tab_->frame_rate().flipped(), olive::PIX_FMT_RGBA32F, olive::kOnline); + VideoRenderingParams video_render_params(dest_width, dest_height, video_tab_->frame_rate().flipped(), PixelFormat::PIX_FMT_RGBA32F, RenderMode::kOnline); // FIXME: Hardcoded sample format AudioRenderingParams audio_render_params(audio_tab_->sample_rate_combobox()->currentData().toInt(), diff --git a/app/dialog/footageproperties/footageproperties.cpp b/app/dialog/footageproperties/footageproperties.cpp index 64fe6755e..a43b24b9b 100644 --- a/app/dialog/footageproperties/footageproperties.cpp +++ b/app/dialog/footageproperties/footageproperties.cpp @@ -31,10 +31,10 @@ #include #include +#include "core.h" #include "render/colormanager.h" #include "streamproperties/audiostreamproperties.h" #include "streamproperties/videostreamproperties.h" -#include "undo/undostack.h" FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, Footage *footage) : QDialog(parent), @@ -117,7 +117,7 @@ void FootagePropertiesDialog::accept() { static_cast(stacked_widget_->widget(i))->Accept(command); } - olive::undo_stack.pushIfHasChildren(command); + Core::instance()->undo_stack()->pushIfHasChildren(command); QDialog::accept(); } diff --git a/app/dialog/projectproperties/projectproperties.cpp b/app/dialog/projectproperties/projectproperties.cpp index 3bc78bbe4..3e0a9cde9 100644 --- a/app/dialog/projectproperties/projectproperties.cpp +++ b/app/dialog/projectproperties/projectproperties.cpp @@ -36,7 +36,7 @@ namespace OCIO = OCIO_NAMESPACE::v1; ProjectPropertiesDialog::ProjectPropertiesDialog(QWidget *parent) : QDialog(parent), - working_project_(olive::core.GetActiveProject()) + working_project_(Core::instance()->GetActiveProject()) { QVBoxLayout* layout = new QVBoxLayout(this); diff --git a/app/dialog/sequence/sequence.cpp b/app/dialog/sequence/sequence.cpp index c49aa6c1a..86042a5bd 100644 --- a/app/dialog/sequence/sequence.cpp +++ b/app/dialog/sequence/sequence.cpp @@ -177,7 +177,7 @@ void SequenceDialog::accept() audio_params, name_field_->text()); - olive::undo_stack.push(param_command); + Core::instance()->undo_stack()->push(param_command); } else { // Set sequence values directly with no undo command diff --git a/app/dialog/speedduration/speedduration.cpp b/app/dialog/speedduration/speedduration.cpp index 1fb04f657..b3c7480d6 100644 --- a/app/dialog/speedduration/speedduration.cpp +++ b/app/dialog/speedduration/speedduration.cpp @@ -7,8 +7,8 @@ #include #include +#include "core.h" #include "common/timecodefunctions.h" -#include "undo/undostack.h" #include "widget/nodeview/nodeviewundo.h" #include "widget/timelinewidget/undo/undo.h" @@ -241,7 +241,7 @@ void SpeedDurationDialog::accept() } } - olive::undo_stack.pushIfHasChildren(command); + Core::instance()->undo_stack()->pushIfHasChildren(command); QDialog::accept(); } diff --git a/app/main.cpp b/app/main.cpp index fa7d5dbf6..b1f85b3e7 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -85,13 +85,13 @@ int main(int argc, char *argv[]) { #endif // Start core - olive::core.Start(); + Core::instance()->Start(); // Run application loop and receive exit code int exit_code = a.exec(); // Clear core memory - olive::core.Stop(); + Core::instance()->Stop(); return exit_code; } diff --git a/app/panel/project/project.cpp b/app/panel/project/project.cpp index cfb0adb11..fbd6b2441 100644 --- a/app/panel/project/project.cpp +++ b/app/panel/project/project.cpp @@ -57,9 +57,9 @@ ProjectPanel::ProjectPanel(QWidget *parent) : // Connect toolbar's view change signal to the explorer's view change slot connect(toolbar, - SIGNAL(ViewChanged(olive::ProjectViewType)), + &ProjectToolbar::ViewChanged, explorer_, - SLOT(set_view_type(olive::ProjectViewType))); + &ProjectExplorer::set_view_type); // Set strings Retranslate(); @@ -120,7 +120,7 @@ void ProjectPanel::ItemDoubleClickSlot(Item *item) { if (item == nullptr) { // If the user double clicks on empty space, show the import dialog - olive::core.DialogImportShow(); + Core::instance()->DialogImportShow(); } // FIXME: Double click Item should do something @@ -130,7 +130,7 @@ void ProjectPanel::ShowNewMenu() { Menu new_menu(this); - olive::menu_shared.AddItemsForNewMenu(&new_menu); + MenuShared::instance()->AddItemsForNewMenu(&new_menu); new_menu.exec(QCursor::pos()); } diff --git a/app/panel/taskmanager/taskmanager.cpp b/app/panel/taskmanager/taskmanager.cpp index 6019ece33..c224e96c7 100644 --- a/app/panel/taskmanager/taskmanager.cpp +++ b/app/panel/taskmanager/taskmanager.cpp @@ -35,7 +35,7 @@ TaskManagerPanel::TaskManagerPanel(QWidget* parent) : setWidget(view_); // Connect task view to the task manager - connect(&olive::task_manager, SIGNAL(TaskAdded(Task*)), view_, SLOT(AddTask(Task*))); + connect(TaskManager::instance(), &TaskManager::TaskAdded, view_, &TaskView::AddTask); // Set strings Retranslate(); diff --git a/app/panel/tool/tool.cpp b/app/panel/tool/tool.cpp index 326c4cc35..815226df1 100644 --- a/app/panel/tool/tool.cpp +++ b/app/panel/tool/tool.cpp @@ -31,16 +31,16 @@ ToolPanel::ToolPanel(QWidget *parent) : Toolbar* t = new Toolbar(this); - t->SetTool(olive::core.tool()); - t->SetSnapping(olive::core.snapping()); + t->SetTool(Core::instance()->tool()); + t->SetSnapping(Core::instance()->snapping()); setWidget(t); - connect(t, SIGNAL(ToolChanged(const olive::tool::Tool&)), &olive::core, SLOT(SetTool(const olive::tool::Tool&))); - connect(&olive::core, SIGNAL(ToolChanged(const olive::tool::Tool&)), t, SLOT(SetTool(const olive::tool::Tool&))); + connect(t, SIGNAL(ToolChanged(const Tool::Item&)), Core::instance(), SLOT(SetTool(const Tool::Item&))); + connect(Core::instance(), SIGNAL(ToolChanged(const Tool::Item&)), t, SLOT(SetTool(const Tool::Item&))); - connect(t, SIGNAL(SnappingChanged(const bool&)), &olive::core, SLOT(SetSnapping(const bool&))); - connect(&olive::core, SIGNAL(SnappingChanged(const bool&)), t, SLOT(SetSnapping(const bool&))); + connect(t, SIGNAL(SnappingChanged(const bool&)), Core::instance(), SLOT(SetSnapping(const bool&))); + connect(Core::instance(), SIGNAL(SnappingChanged(const bool&)), t, SLOT(SetSnapping(const bool&))); Retranslate(); } diff --git a/app/project/projectviewmodel.cpp b/app/project/projectviewmodel.cpp index 8c6dee3b2..f69489552 100644 --- a/app/project/projectviewmodel.cpp +++ b/app/project/projectviewmodel.cpp @@ -25,7 +25,6 @@ #include #include "core.h" -#include "undo/undostack.h" ProjectViewModel::ProjectViewModel(QObject *parent) : QAbstractItemModel(parent), @@ -197,7 +196,7 @@ bool ProjectViewModel::setData(const QModelIndex &index, const QVariant &value, RenameItemCommand* ric = new RenameItemCommand(this, item, value.toString()); - olive::undo_stack.push(ric); + Core::instance()->undo_stack()->push(ric); return true; } @@ -338,7 +337,7 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data, Qt::DropAction action } } - olive::undo_stack.pushIfHasChildren(move_command); + Core::instance()->undo_stack()->pushIfHasChildren(move_command); return true; @@ -368,7 +367,7 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data, Qt::DropAction action } // Trigger an import - olive::core.ImportFiles(urls, this, static_cast(drop_item)); + Core::instance()->ImportFiles(urls, this, static_cast(drop_item)); } return false; diff --git a/app/project/projectviewtype.h b/app/project/projectviewtype.h deleted file mode 100644 index 7194d1aff..000000000 --- a/app/project/projectviewtype.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef PROJECTVIEWTYPE_H -#define PROJECTVIEWTYPE_H - -namespace olive { -enum ProjectViewType { - TreeView, - ListView, - IconView -}; -} - -#endif // PROJECTVIEWTYPE_H diff --git a/app/render/backend/exporter.cpp b/app/render/backend/exporter.cpp index 0d34f1783..5d9128133 100644 --- a/app/render/backend/exporter.cpp +++ b/app/render/backend/exporter.cpp @@ -117,8 +117,8 @@ void Exporter::FrameRendered(const rational &time, QVariant value) FramePtr frame = TextureToFrame(value); // OCIO conversion requires a frame in 32F format - if (frame->format() != olive::PIX_FMT_RGBA32F) { - frame = PixelService::ConvertPixelFormat(frame, olive::PIX_FMT_RGBA32F); + if (frame->format() != PixelFormat::PIX_FMT_RGBA32F) { + frame = PixelService::ConvertPixelFormat(frame, PixelFormat::PIX_FMT_RGBA32F); } // Color conversion must be done with unassociated alpha, and the pipeline is always associated diff --git a/app/render/backend/opengl/CMakeLists.txt b/app/render/backend/opengl/CMakeLists.txt index a0fc0d6f3..1911e4d73 100644 --- a/app/render/backend/opengl/CMakeLists.txt +++ b/app/render/backend/opengl/CMakeLists.txt @@ -16,8 +16,6 @@ set(OLIVE_SOURCES ${OLIVE_SOURCES} - render/backend/opengl/functions.h - render/backend/opengl/functions.cpp render/backend/opengl/openglbackend.h render/backend/opengl/openglbackend.cpp render/backend/opengl/openglcolorprocessor.h @@ -26,6 +24,8 @@ set(OLIVE_SOURCES render/backend/opengl/openglexporter.cpp render/backend/opengl/openglframebuffer.h render/backend/opengl/openglframebuffer.cpp + render/backend/opengl/openglrenderfunctions.h + render/backend/opengl/openglrenderfunctions.cpp render/backend/opengl/openglshader.h render/backend/opengl/openglshader.cpp render/backend/opengl/openglshadercache.h diff --git a/app/render/backend/opengl/openglbackend.cpp b/app/render/backend/opengl/openglbackend.cpp index 5d2c4af3a..6f8dbe184 100644 --- a/app/render/backend/opengl/openglbackend.cpp +++ b/app/render/backend/opengl/openglbackend.cpp @@ -3,7 +3,7 @@ #include #include -#include "functions.h" +#include "openglrenderfunctions.h" OpenGLBackend::OpenGLBackend(QObject *parent) : VideoRenderBackend(parent), @@ -168,7 +168,7 @@ OpenGLTexturePtr OpenGLBackend::CopyTexture(OpenGLTexturePtr input) copy_buffer_.Bind(); input->Bind(); - olive::gl::Blit(copy_pipeline_); + OpenGLRenderFunctions::Blit(copy_pipeline_); input->Release(); copy_buffer_.Release(); diff --git a/app/render/backend/opengl/openglcolorprocessor.cpp b/app/render/backend/opengl/openglcolorprocessor.cpp index afa6b6090..404bb2bbd 100644 --- a/app/render/backend/opengl/openglcolorprocessor.cpp +++ b/app/render/backend/opengl/openglcolorprocessor.cpp @@ -3,7 +3,7 @@ #include #include -#include "functions.h" +#include "openglrenderfunctions.h" void OpenGLColorProcessor::Enable(QOpenGLContext *context, bool alpha_is_associated) { @@ -31,7 +31,7 @@ OpenGLShaderPtr OpenGLColorProcessor::pipeline() const void OpenGLColorProcessor::ProcessOpenGL() { - olive::gl::OCIOBlit(pipeline_, ocio_lut_); + OpenGLRenderFunctions::OCIOBlit(pipeline_, ocio_lut_); } OpenGLColorProcessor::OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space) : diff --git a/app/render/backend/opengl/openglexporter.cpp b/app/render/backend/opengl/openglexporter.cpp index 6728e9a75..e85a03e15 100644 --- a/app/render/backend/opengl/openglexporter.cpp +++ b/app/render/backend/opengl/openglexporter.cpp @@ -1,6 +1,6 @@ #include "openglexporter.h" -#include "render/backend/opengl/functions.h" +#include "render/backend/opengl/openglrenderfunctions.h" #include "render/pixelservice.h" OpenGLExporter::OpenGLExporter(ViewerOutput* viewer, const VideoRenderingParams& video_params, const AudioRenderingParams &audio_params, const QMatrix4x4 &transform, ColorProcessorPtr color_processor, Encoder *encoder, QObject* parent) : @@ -55,7 +55,7 @@ FramePtr OpenGLExporter::TextureToFrame(const QVariant& texture) buffer_.Bind(); input_tex->Bind(); - olive::gl::Blit(pipeline_, false, transform_); + OpenGLRenderFunctions::Blit(pipeline_, false, transform_); input_tex->Release(); buffer_.Release(); @@ -65,7 +65,7 @@ FramePtr OpenGLExporter::TextureToFrame(const QVariant& texture) buffer_.Attach(texture_); buffer_.Bind(); - PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(video_params_.format()); + PixelFormat::Info format_info = PixelService::GetPixelFormatInfo(video_params_.format()); f->glReadPixels(0, 0, diff --git a/app/render/backend/opengl/functions.cpp b/app/render/backend/opengl/openglrenderfunctions.cpp similarity index 92% rename from app/render/backend/opengl/functions.cpp rename to app/render/backend/opengl/openglrenderfunctions.cpp index c00223560..48c33d2cd 100644 --- a/app/render/backend/opengl/functions.cpp +++ b/app/render/backend/opengl/openglrenderfunctions.cpp @@ -18,7 +18,7 @@ ***/ -#include "functions.h" +#include "openglrenderfunctions.h" #include #include @@ -63,7 +63,7 @@ const GLfloat flipped_blit_texcoords[] = { * * Currently active QOpenGLFunctions object (use context()->functions() if unsure). */ -void olive::gl::PrepareToDraw(QOpenGLFunctions* f) { +void OpenGLRenderFunctions::PrepareToDraw(QOpenGLFunctions* f) { f->glGenerateMipmap(GL_TEXTURE_2D); f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -71,7 +71,7 @@ void olive::gl::PrepareToDraw(QOpenGLFunctions* f) { f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } -void olive::gl::Blit(OpenGLShaderPtr pipeline, bool flipped, QMatrix4x4 matrix) { +void OpenGLRenderFunctions::Blit(OpenGLShaderPtr pipeline, bool flipped, QMatrix4x4 matrix) { // FIXME: is currentContext() reliable here? QOpenGLFunctions* func = QOpenGLContext::currentContext()->functions(); @@ -123,7 +123,7 @@ void olive::gl::Blit(OpenGLShaderPtr pipeline, bool flipped, QMatrix4x4 matrix) func->glFinish(); } -void olive::gl::OCIOBlit(OpenGLShaderPtr pipeline, +void OpenGLRenderFunctions::OCIOBlit(OpenGLShaderPtr pipeline, GLuint lut, bool flipped, QMatrix4x4 matrix) @@ -139,7 +139,7 @@ void olive::gl::OCIOBlit(OpenGLShaderPtr pipeline, pipeline->setUniformValue("ove_ociolut", 2); - olive::gl::Blit(pipeline, flipped, matrix); + OpenGLRenderFunctions::Blit(pipeline, flipped, matrix); pipeline->release(); diff --git a/app/render/backend/opengl/functions.h b/app/render/backend/opengl/openglrenderfunctions.h similarity index 58% rename from app/render/backend/opengl/functions.h rename to app/render/backend/opengl/openglrenderfunctions.h index 779dfce78..493f29995 100644 --- a/app/render/backend/opengl/functions.h +++ b/app/render/backend/opengl/openglrenderfunctions.h @@ -26,31 +26,28 @@ #include "openglshader.h" -namespace olive { -namespace gl { +class OpenGLRenderFunctions { +public: + /** + * @brief Draw texture on screen + * + * @param pipeline + * + * Shader to use for the texture drawing + * + * @param flipped + * + * Draw the texture vertically flipped (defaults to FALSE) + * + * @param matrix + * + * Transformation matrix to use when drawing (defaults to no transform) + */ + static void Blit(OpenGLShaderPtr pipeline, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4()); -/** - * @brief Draw texture on screen - * - * @param pipeline - * - * Shader to use for the texture drawing - * - * @param flipped - * - * Draw the texture vertically flipped (defaults to FALSE) - * - * @param matrix - * - * Transformation matrix to use when drawing (defaults to no transform) - */ -void Blit(OpenGLShaderPtr pipeline, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4()); + static void OCIOBlit(OpenGLShaderPtr pipeline, GLuint lut, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4()); -void OCIOBlit(OpenGLShaderPtr pipeline, GLuint lut, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4()); - -void PrepareToDraw(QOpenGLFunctions* f); - -} -} + static void PrepareToDraw(QOpenGLFunctions* f); +}; #endif // OPENGLFUNCTIONS_H diff --git a/app/render/backend/opengl/opengltexture.cpp b/app/render/backend/opengl/opengltexture.cpp index e8123608d..036ef6096 100644 --- a/app/render/backend/opengl/opengltexture.cpp +++ b/app/render/backend/opengl/opengltexture.cpp @@ -30,7 +30,7 @@ OpenGLTexture::OpenGLTexture() : texture_(0), width_(0), height_(0), - format_(olive::PIX_FMT_INVALID) + format_(PixelFormat::PIX_FMT_INVALID) { } @@ -44,7 +44,7 @@ bool OpenGLTexture::IsCreated() const return (texture_); } -void OpenGLTexture::Create(QOpenGLContext *ctx, int width, int height, const olive::PixelFormat &format, const void* data) +void OpenGLTexture::Create(QOpenGLContext *ctx, int width, int height, const PixelFormat::Format &format, const void* data) { if (!ctx) { qWarning() << "OpenGLTexture::Create was passed an invalid context"; @@ -115,7 +115,7 @@ const int &OpenGLTexture::height() const return height_; } -const olive::PixelFormat &OpenGLTexture::format() const +const PixelFormat::Format &OpenGLTexture::format() const { return format_; } @@ -141,7 +141,7 @@ void OpenGLTexture::Upload(const void *data) Bind(); - PixelFormatInfo info = PixelService::GetPixelFormatInfo(format_); + PixelFormat::Info info = PixelService::GetPixelFormatInfo(format_); context->functions()->glTexSubImage2D(GL_TEXTURE_2D, 0, @@ -173,7 +173,7 @@ void OpenGLTexture::CreateInternal(QOpenGLContext* create_ctx, GLuint* tex, cons f->glBindTexture(GL_TEXTURE_2D, *tex); // Allocate storage for texture - const PixelFormatInfo& bit_depth = PixelService::GetPixelFormatInfo(format_); + const PixelFormat::Info& bit_depth = PixelService::GetPixelFormatInfo(format_); f->glTexImage2D( GL_TEXTURE_2D, diff --git a/app/render/backend/opengl/opengltexture.h b/app/render/backend/opengl/opengltexture.h index 92b061234..ef1c7c23e 100644 --- a/app/render/backend/opengl/opengltexture.h +++ b/app/render/backend/opengl/opengltexture.h @@ -40,7 +40,7 @@ public: DISABLE_COPY_MOVE(OpenGLTexture) - void Create(QOpenGLContext* ctx, int width, int height, const olive::PixelFormat &format, const void *data = nullptr); + void Create(QOpenGLContext* ctx, int width, int height, const PixelFormat::Format &format, const void *data = nullptr); void Create(QOpenGLContext* ctx, FramePtr frame); bool IsCreated() const; @@ -53,7 +53,7 @@ public: const int& height() const; - const olive::PixelFormat &format() const; + const PixelFormat::Format &format() const; const GLuint& texture() const; @@ -73,7 +73,7 @@ private: int height_; - olive::PixelFormat format_; + PixelFormat::Format format_; }; diff --git a/app/render/backend/opengl/openglworker.cpp b/app/render/backend/opengl/openglworker.cpp index eaed586f4..c5057850a 100644 --- a/app/render/backend/opengl/openglworker.cpp +++ b/app/render/backend/opengl/openglworker.cpp @@ -2,10 +2,10 @@ #include "common/clamp.h" #include "core.h" -#include "functions.h" #include "node/block/transition/transition.h" #include "node/node.h" #include "openglcolorprocessor.h" +#include "openglrenderfunctions.h" #include "render/colormanager.h" #include "render/pixelservice.h" @@ -72,14 +72,14 @@ void OpenGLWorker::FrameToValue(StreamPtr stream, FramePtr frame, NodeValueTable } // OCIO's CPU conversion is more accurate, so for online we render on CPU but offline we render GPU - if (video_params().mode() == olive::kOnline) { + if (video_params().mode() == RenderMode::kOnline) { // If alpha is associated, disassociate for the color transform if (video_stream->premultiplied_alpha()) { ColorManager::DisassociateAlpha(frame); } // Convert frame to float for OCIO - frame = PixelService::ConvertPixelFormat(frame, olive::PIX_FMT_RGBA32F); + frame = PixelService::ConvertPixelFormat(frame, PixelFormat::PIX_FMT_RGBA32F); // Perform color transform color_processor->ConvertFrame(frame); @@ -96,7 +96,7 @@ void OpenGLWorker::FrameToValue(StreamPtr stream, FramePtr frame, NodeValueTable OpenGLTextureCache::ReferencePtr footage_tex_ref = texture_cache_->Get(ctx_, footage_params, frame->data()); - if (video_params().mode() == olive::kOffline) { + if (video_params().mode() == RenderMode::kOffline) { if (!color_processor->IsEnabled()) { color_processor->Enable(ctx_, video_stream->premultiplied_alpha()); } @@ -238,7 +238,7 @@ void OpenGLWorker::RunNodeAccelerated(const Node *node, const TimeRange &range, iterative_input = input_texture_count; } - olive::gl::PrepareToDraw(functions_); + OpenGLRenderFunctions::PrepareToDraw(functions_); input_texture_count++; break; @@ -322,7 +322,7 @@ void OpenGLWorker::RunNodeAccelerated(const Node *node, const TimeRange &range, buffer_.Bind(); // Blit this texture through this shader - olive::gl::Blit(shader); + OpenGLRenderFunctions::Blit(shader); buffer_.Release(); buffer_.Detach(); @@ -353,7 +353,7 @@ void OpenGLWorker::TextureToBuffer(const QVariant &tex_in, QByteArray &buffer) { OpenGLTextureCache::ReferencePtr texture = tex_in.value(); - PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(video_params().format()); + PixelFormat::Info format_info = PixelService::GetPixelFormatInfo(video_params().format()); QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions(); buffer_.Attach(texture->texture()); diff --git a/app/render/backend/videorenderworker.cpp b/app/render/backend/videorenderworker.cpp index 3c670baef..b2adc465a 100644 --- a/app/render/backend/videorenderworker.cpp +++ b/app/render/backend/videorenderworker.cpp @@ -136,7 +136,7 @@ void VideoRenderWorker::CloseInternal() void VideoRenderWorker::Download(NodeDependency dep, QByteArray hash, QVariant texture, QString filename) { - PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(video_params().format()); + PixelFormat::Info format_info = PixelService::GetPixelFormatInfo(video_params().format()); // Set up OIIO::ImageSpec for compressing cached images on disk OIIO::ImageSpec spec(video_params().effective_width(), video_params().effective_height(), kRGBAChannels, format_info.oiio_desc); diff --git a/app/render/colormanager.cpp b/app/render/colormanager.cpp index f465ca2ca..7e1d33e82 100644 --- a/app/render/colormanager.cpp +++ b/app/render/colormanager.cpp @@ -114,21 +114,21 @@ void ColorManager::AssociateAlphaPixFmtFilter(ColorManager::AlphaAction action, { int pixel_count = f->width() * f->height() * kRGBAChannels; - switch (static_cast(f->format())) { - case olive::PIX_FMT_INVALID: - case olive::PIX_FMT_COUNT: + switch (static_cast(f->format())) { + case PixelFormat::PIX_FMT_INVALID: + case PixelFormat::PIX_FMT_COUNT: qWarning() << "Alpha association functions received an invalid pixel format"; break; - case olive::PIX_FMT_RGBA8: - case olive::PIX_FMT_RGBA16U: + case PixelFormat::PIX_FMT_RGBA8: + case PixelFormat::PIX_FMT_RGBA16U: qWarning() << "Alpha association functions only works on float-based pixel formats at this time"; break; - case olive::PIX_FMT_RGBA16F: + case PixelFormat::PIX_FMT_RGBA16F: { AssociateAlphaInternal(action, reinterpret_cast(f->data()), pixel_count); break; } - case olive::PIX_FMT_RGBA32F: + case PixelFormat::PIX_FMT_RGBA32F: { AssociateAlphaInternal(action, reinterpret_cast(f->data()), pixel_count); break; diff --git a/app/render/pixelformat.h b/app/render/pixelformat.h index b8594da58..918d65ad8 100644 --- a/app/render/pixelformat.h +++ b/app/render/pixelformat.h @@ -21,22 +21,44 @@ #ifndef BITDEPTHS_H #define BITDEPTHS_H -namespace olive { +#include +#include +#include -/** - * @brief Olive's internal supported pixel formats. - */ -enum PixelFormat { - PIX_FMT_INVALID = -1, +class PixelFormat { +public: + /** + * @brief Olive's internal supported pixel formats. + */ + enum Format { + PIX_FMT_INVALID = -1, - PIX_FMT_RGBA8, - PIX_FMT_RGBA16U, - PIX_FMT_RGBA16F, - PIX_FMT_RGBA32F, + PIX_FMT_RGBA8, + PIX_FMT_RGBA16U, + PIX_FMT_RGBA16F, + PIX_FMT_RGBA32F, - PIX_FMT_COUNT + PIX_FMT_COUNT + }; + + /** + * @brief A struct of information pertaining to each enum PixelFormat. + * + * Primarily this is a means of retrieving OpenGL texture information for different pixel formats/bit depths. Both + * RAM and VRAM buffers will need a PixelFormat. To keep consistency between the OpenGL code and CPU code when using + * a given PixelFormat, the PixelFormatInfo struct contains all necessary variables that you'll need to plug into + * OpenGL. + * + * Use the static function PixelService::GetPixelFormatInfo to generate a PixelFormatInfo object. + */ + struct Info { + QString name; + GLint internal_format; + GLenum pixel_format; + GLenum gl_pixel_type; + int bytes_per_pixel; + OIIO::TypeDesc oiio_desc; + }; }; -} - #endif // BITDEPTHS_H diff --git a/app/render/pixelservice.cpp b/app/render/pixelservice.cpp index 0749796af..603f9fd4c 100644 --- a/app/render/pixelservice.cpp +++ b/app/render/pixelservice.cpp @@ -30,37 +30,37 @@ PixelService::PixelService() { } -PixelFormatInfo PixelService::GetPixelFormatInfo(const olive::PixelFormat &format) +PixelFormat::Info PixelService::GetPixelFormatInfo(const PixelFormat::Format &format) { - PixelFormatInfo info; + PixelFormat::Info info; switch (format) { - case olive::PIX_FMT_RGBA8: + case PixelFormat::PIX_FMT_RGBA8: info.name = tr("8-bit"); info.internal_format = GL_RGBA8; info.gl_pixel_type = GL_UNSIGNED_BYTE; info.oiio_desc = OIIO::TypeDesc::UINT8; break; - case olive::PIX_FMT_RGBA16U: + case PixelFormat::PIX_FMT_RGBA16U: info.name = tr("16-bit Integer"); info.internal_format = GL_RGBA16; info.gl_pixel_type = GL_UNSIGNED_SHORT; info.oiio_desc = OIIO::TypeDesc::UINT16; break; - case olive::PIX_FMT_RGBA16F: + case PixelFormat::PIX_FMT_RGBA16F: info.name = tr("Half-Float (16-bit)"); info.internal_format = GL_RGBA16F; info.gl_pixel_type = GL_HALF_FLOAT; info.oiio_desc = OIIO::TypeDesc::HALF; break; - case olive::PIX_FMT_RGBA32F: + case PixelFormat::PIX_FMT_RGBA32F: info.name = tr("Full-Float (32-bit)"); info.internal_format = GL_RGBA32F; info.gl_pixel_type = GL_FLOAT; info.oiio_desc = OIIO::TypeDesc::FLOAT; break; - case olive::PIX_FMT_INVALID: - case olive::PIX_FMT_COUNT: + case PixelFormat::PIX_FMT_INVALID: + case PixelFormat::PIX_FMT_COUNT: qFatal("Invalid pixel format requested"); } @@ -70,28 +70,28 @@ PixelFormatInfo PixelService::GetPixelFormatInfo(const olive::PixelFormat &forma return info; } -int PixelService::GetBufferSize(const olive::PixelFormat &format, const int &width, const int &height) +int PixelService::GetBufferSize(const PixelFormat::Format &format, const int &width, const int &height) { return BytesPerPixel(format) * width * height; } -int PixelService::BytesPerPixel(const olive::PixelFormat &format) +int PixelService::BytesPerPixel(const PixelFormat::Format &format) { return BytesPerChannel(format) * kRGBAChannels; } -int PixelService::BytesPerChannel(const olive::PixelFormat &format) +int PixelService::BytesPerChannel(const PixelFormat::Format &format) { switch (format) { - case olive::PIX_FMT_RGBA8: + case PixelFormat::PIX_FMT_RGBA8: return 1; - case olive::PIX_FMT_RGBA16U: - case olive::PIX_FMT_RGBA16F: + case PixelFormat::PIX_FMT_RGBA16U: + case PixelFormat::PIX_FMT_RGBA16F: return 2; - case olive::PIX_FMT_RGBA32F: + case PixelFormat::PIX_FMT_RGBA32F: return 4; - case olive::PIX_FMT_INVALID: - case olive::PIX_FMT_COUNT: + case PixelFormat::PIX_FMT_INVALID: + case PixelFormat::PIX_FMT_COUNT: break; } @@ -101,7 +101,7 @@ int PixelService::BytesPerChannel(const olive::PixelFormat &format) return 0; } -FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelFormat &dest_format) +FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const PixelFormat::Format &dest_format) { if (frame->format() == dest_format) { return frame; @@ -122,13 +122,13 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm bool valid = true; - switch (static_cast(frame->format())) { - case olive::PIX_FMT_RGBA8: + switch (static_cast(frame->format())) { + case PixelFormat::PIX_FMT_RGBA8: { uint8_t* source = reinterpret_cast(frame->data()); switch (dest_format) { - case olive::PIX_FMT_RGBA16U: // 8-bit Integer -> 16-bit Integer + case PixelFormat::PIX_FMT_RGBA16U: // 8-bit Integer -> 16-bit Integer { uint16_t* destination = reinterpret_cast(converted->data()); for (int i=0;i 16-bit Float + case PixelFormat::PIX_FMT_RGBA16F: // 8-bit Integer -> 16-bit Float { qfloat16* destination = reinterpret_cast(converted->data()); for (int i=0;i 32-bit Float + case PixelFormat::PIX_FMT_RGBA32F: // 8-bit Integer -> 32-bit Float { float* destination = reinterpret_cast(converted->data()); for (int i=0;i(frame->data()); switch (dest_format) { - case olive::PIX_FMT_RGBA8: // 16-bit Integer -> 8-bit Integer + case PixelFormat::PIX_FMT_RGBA8: // 16-bit Integer -> 8-bit Integer { uint8_t* destination = reinterpret_cast(converted->data()); for (int i=0;i 16-bit Float + case PixelFormat::PIX_FMT_RGBA16F: // 16-bit Integer -> 16-bit Float { qfloat16* destination = reinterpret_cast(converted->data()); for (int i=0;i 32-bit Float + case PixelFormat::PIX_FMT_RGBA32F: // 16-bit Integer -> 32-bit Float { float* destination = reinterpret_cast(converted->data()); for (int i=0;i(frame->data()); switch (dest_format) { - case olive::PIX_FMT_RGBA8: // 16-bit Float -> 8-bit Integer + case PixelFormat::PIX_FMT_RGBA8: // 16-bit Float -> 8-bit Integer { uint8_t* destination = reinterpret_cast(converted->data()); for (int i=0;i 16-bit Integer + case PixelFormat::PIX_FMT_RGBA16U: // 16-bit Float -> 16-bit Integer { uint16_t* destination = reinterpret_cast(converted->data()); for (int i=0;i 32-bit Float + case PixelFormat::PIX_FMT_RGBA32F: // 16-bit Float -> 32-bit Float { float* destination = reinterpret_cast(converted->data()); for (int i=0;i(frame->data()); switch (dest_format) { - case olive::PIX_FMT_RGBA8: // 32-bit Float -> 8-bit Integer + case PixelFormat::PIX_FMT_RGBA8: // 32-bit Float -> 8-bit Integer { uint8_t* destination = reinterpret_cast(converted->data()); for (int i=0;i 16-bit Integer + case PixelFormat::PIX_FMT_RGBA16U: // 32-bit Float -> 16-bit Integer { uint16_t* destination = reinterpret_cast(converted->data()); for (int i=0;i 16-bit Float + case PixelFormat::PIX_FMT_RGBA16F: // 32-bit Float -> 16-bit Float { qfloat16* destination = reinterpret_cast(converted->data()); for (int i=0;i(frame->format()); + PixelFormat::Format dest_format = static_cast(frame->format()); int rgb_pixel_size = BytesPerChannel(dest_format) * kRGBChannels; int rgb_frame_size = frame->width() * frame->height() * rgb_pixel_size; @@ -300,20 +300,20 @@ void PixelService::ConvertRGBtoRGBA(FramePtr frame) // Write a full alpha value according to the format switch (dest_format) { - case olive::PIX_FMT_RGBA8: + case PixelFormat::PIX_FMT_RGBA8: *alpha_ptr = UINT8_MAX; break; - case olive::PIX_FMT_RGBA16U: + case PixelFormat::PIX_FMT_RGBA16U: *reinterpret_cast(alpha_ptr) = UINT16_MAX; break; - case olive::PIX_FMT_RGBA16F: + case PixelFormat::PIX_FMT_RGBA16F: *reinterpret_cast(alpha_ptr) = 1.0f; break; - case olive::PIX_FMT_RGBA32F: + case PixelFormat::PIX_FMT_RGBA32F: *reinterpret_cast(alpha_ptr) = 1.0f; break; - case olive::PIX_FMT_INVALID: - case olive::PIX_FMT_COUNT: + case PixelFormat::PIX_FMT_INVALID: + case PixelFormat::PIX_FMT_COUNT: qFatal("Invalid pixel format requested"); } diff --git a/app/render/pixelservice.h b/app/render/pixelservice.h index 94c4331a3..921a8e304 100644 --- a/app/render/pixelservice.h +++ b/app/render/pixelservice.h @@ -22,31 +22,10 @@ #define PIXELSERVICE_H #include -#include -#include #include "codec/frame.h" #include "pixelformat.h" -/** - * @brief A struct of information pertaining to each enum PixelFormat. - * - * Primarily this is a means of retrieving OpenGL texture information for different pixel formats/bit depths. Both - * RAM and VRAM buffers will need a PixelFormat. To keep consistency between the OpenGL code and CPU code when using - * a given PixelFormat, the PixelFormatInfo struct contains all necessary variables that you'll need to plug into - * OpenGL. - * - * Use the static function PixelService::GetPixelFormatInfo to generate a PixelFormatInfo object. - */ -struct PixelFormatInfo { - QString name; - GLint internal_format; - GLenum pixel_format; - GLenum gl_pixel_type; - int bytes_per_pixel; - OIIO::TypeDesc oiio_desc; -}; - class PixelService : public QObject { public: @@ -57,7 +36,7 @@ public: * * \see PixelFormatInfo */ - static PixelFormatInfo GetPixelFormatInfo(const olive::PixelFormat& format); + static PixelFormat::Info GetPixelFormatInfo(const PixelFormat::Format& format); /** * @brief Returns the minimum buffer size (in bytes) necessary for a given format, width, and height. @@ -74,7 +53,7 @@ public: * * The height (in pixels) of the buffer. */ - static int GetBufferSize(const olive::PixelFormat &format, const int& width, const int& height); + static int GetBufferSize(const PixelFormat::Format &format, const int& width, const int& height); /** * @brief Returns the number of bytes per pixel for a certain format @@ -83,19 +62,19 @@ public: * requires for a certain format. The number of bytes will always be a multiple of 4 since all formats use RGBA and * are at least 1 bpc. */ - static int BytesPerPixel(const olive::PixelFormat& format); + static int BytesPerPixel(const PixelFormat::Format &format); /** * @brief Returns the number of bytes per channel for a certain format */ - static int BytesPerChannel(const olive::PixelFormat& format); + static int BytesPerChannel(const PixelFormat::Format& format); /** * @brief Convert a frame to a pixel format * * If the frame's pixel format == the destination format, this just returns `frame`. */ - static FramePtr ConvertPixelFormat(FramePtr frame, const olive::PixelFormat &dest_format); + static FramePtr ConvertPixelFormat(FramePtr frame, const PixelFormat::Format &dest_format); /** * @brief Convert an RGB image to an RGBA image diff --git a/app/render/rendermodes.h b/app/render/rendermodes.h index b13eb2fd3..0477474bc 100644 --- a/app/render/rendermodes.h +++ b/app/render/rendermodes.h @@ -1,25 +1,24 @@ #ifndef RENDERMODE_H #define RENDERMODE_H -namespace olive { - -/** - * @brief The primary different "modes" the renderer can function in - */ -enum RenderMode { +class RenderMode { +public: /** - * This render is for realtime preview ONLY and does not need to be "perfect". Nodes can use lower-accuracy functions - * to save performance when possible. + * @brief The primary different "modes" the renderer can function in */ - kOffline, + enum Mode { + /** + * This render is for realtime preview ONLY and does not need to be "perfect". Nodes can use lower-accuracy functions + * to save performance when possible. + */ + kOffline, - /** - * This render is some sort of export or master copy and Nodes should take time/bandwidth/system resources to produce - * a higher accuracy version. - */ - kOnline + /** + * This render is some sort of export or master copy and Nodes should take time/bandwidth/system resources to produce + * a higher accuracy version. + */ + kOnline + }; }; -} - #endif // RENDERMODE_H diff --git a/app/render/videoparams.cpp b/app/render/videoparams.cpp index 84210f6ed..4b26766eb 100644 --- a/app/render/videoparams.cpp +++ b/app/render/videoparams.cpp @@ -30,11 +30,11 @@ const rational &VideoParams::time_base() const } VideoRenderingParams::VideoRenderingParams() : - format_(olive::PIX_FMT_INVALID) + format_(PixelFormat::PIX_FMT_INVALID) { } -VideoRenderingParams::VideoRenderingParams(const int &width, const int &height, const rational &time_base, const olive::PixelFormat &format, const olive::RenderMode& mode, const int ÷r) : +VideoRenderingParams::VideoRenderingParams(const int &width, const int &height, const rational &time_base, const PixelFormat::Format &format, const RenderMode::Mode& mode, const int ÷r) : VideoParams(width, height, time_base), format_(format), mode_(mode), @@ -43,7 +43,7 @@ VideoRenderingParams::VideoRenderingParams(const int &width, const int &height, calculate_effective_size(); } -VideoRenderingParams::VideoRenderingParams(const VideoParams ¶ms, const olive::PixelFormat &format, const olive::RenderMode& mode, const int& divider) : +VideoRenderingParams::VideoRenderingParams(const VideoParams ¶ms, const PixelFormat::Format &format, const RenderMode::Mode& mode, const int& divider) : VideoParams(params), format_(format), mode_(mode), @@ -67,12 +67,12 @@ const int& VideoRenderingParams::effective_height() const return effective_height_; } -const olive::PixelFormat &VideoRenderingParams::format() const +const PixelFormat::Format &VideoRenderingParams::format() const { return format_; } -const olive::RenderMode &VideoRenderingParams::mode() const +const RenderMode::Mode &VideoRenderingParams::mode() const { return mode_; } @@ -88,6 +88,6 @@ bool VideoRenderingParams::is_valid() const return (width() > 0 && height() > 0 && !time_base().isNull() - && format_ != olive::PIX_FMT_INVALID - && format_ != olive::PIX_FMT_COUNT); + && format_ != PixelFormat::PIX_FMT_INVALID + && format_ != PixelFormat::PIX_FMT_COUNT); } diff --git a/app/render/videoparams.h b/app/render/videoparams.h index f2ada83cf..3e9bb52c9 100644 --- a/app/render/videoparams.h +++ b/app/render/videoparams.h @@ -25,22 +25,22 @@ private: class VideoRenderingParams : public VideoParams { public: VideoRenderingParams(); - VideoRenderingParams(const int& width, const int& height, const rational& time_base, const olive::PixelFormat& format, const olive::RenderMode& mode, const int& divider = 1); - VideoRenderingParams(const VideoParams& params, const olive::PixelFormat& format, const olive::RenderMode& mode, const int& divider = 1); + VideoRenderingParams(const int& width, const int& height, const rational& time_base, const PixelFormat::Format& format, const RenderMode::Mode& mode, const int& divider = 1); + VideoRenderingParams(const VideoParams& params, const PixelFormat::Format& format, const RenderMode::Mode& mode, const int& divider = 1); const int& divider() const; const int& effective_width() const; const int& effective_height() const; bool is_valid() const; - const olive::PixelFormat& format() const; - const olive::RenderMode& mode() const; + const PixelFormat::Format& format() const; + const RenderMode::Mode& mode() const; private: void calculate_effective_size(); - olive::PixelFormat format_; - olive::RenderMode mode_; + PixelFormat::Format format_; + RenderMode::Mode mode_; int divider_; int effective_width_; diff --git a/app/task/import/import.cpp b/app/task/import/import.cpp index b2491e5b5..907cdedd5 100644 --- a/app/task/import/import.cpp +++ b/app/task/import/import.cpp @@ -31,10 +31,10 @@ #include "panel/project/project.h" // End test code +#include "core.h" #include "project/item/footage/footage.h" #include "task/probe/probe.h" #include "task/taskmanager.h" -#include "undo/undostack.h" ImportTask::ImportTask(ProjectViewModel *model, Folder *parent, const QStringList &urls) : model_(model), @@ -67,7 +67,7 @@ bool ImportTask::Action() bool ImportTask::Epilogue() { if (command_ != nullptr) { - olive::undo_stack.push(command_); + Core::instance()->undo_stack()->push(command_); } parent_->UnlockDeletes(); diff --git a/app/task/taskmanager.cpp b/app/task/taskmanager.cpp index c27f7ded5..c044fbce8 100644 --- a/app/task/taskmanager.cpp +++ b/app/task/taskmanager.cpp @@ -23,7 +23,7 @@ #include #include -TaskManager olive::task_manager; +TaskManager TaskManager::instance_; TaskManager::TaskManager() { @@ -35,8 +35,13 @@ TaskManager::~TaskManager() Clear(); } +TaskManager *TaskManager::instance() +{ + return &instance_; +} + void TaskManager::AddTask(TaskPtr t) -{ +{ // Connect Task's status signal to the Callback connect(t.get(), SIGNAL(StatusChanged(Task::Status)), this, SLOT(TaskCallback(Task::Status))); @@ -125,12 +130,12 @@ TaskManager::AddTaskCommand::AddTaskCommand(TaskPtr t, QUndoCommand *parent) : void TaskManager::AddTaskCommand::redo() { - olive::task_manager.AddTask(task_); + TaskManager::instance()->AddTask(task_); } void TaskManager::AddTaskCommand::undo() { - olive::task_manager.DeleteTask(task_.get()); + TaskManager::instance()->DeleteTask(task_.get()); task_->ResetState(); } diff --git a/app/task/taskmanager.h b/app/task/taskmanager.h index 24eac4e8a..24962e863 100644 --- a/app/task/taskmanager.h +++ b/app/task/taskmanager.h @@ -70,6 +70,8 @@ public: */ TaskManager& operator=(TaskManager&& other) = delete; + static TaskManager* instance(); + /** * @brief Add a new Task * @@ -165,6 +167,11 @@ private: */ int maximum_task_count_; + /** + * @brief TaskManager singleton instance + */ + static TaskManager instance_; + private slots: /** * @brief Callback when a Task's status changes @@ -180,8 +187,4 @@ private slots: }; -namespace olive { -extern TaskManager task_manager; -} - #endif // TASKMANAGER_H diff --git a/app/undo/undostack.cpp b/app/undo/undostack.cpp index 77879f00c..5904ad312 100644 --- a/app/undo/undostack.cpp +++ b/app/undo/undostack.cpp @@ -20,9 +20,7 @@ #include "undostack.h" -OliveUndoStack olive::undo_stack; - -void OliveUndoStack::pushIfHasChildren(QUndoCommand *command) +void UndoStack::pushIfHasChildren(QUndoCommand *command) { if (command->childCount() > 0) { push(command); diff --git a/app/undo/undostack.h b/app/undo/undostack.h index 65204e6a0..31b4d1b06 100644 --- a/app/undo/undostack.h +++ b/app/undo/undostack.h @@ -23,7 +23,7 @@ #include -class OliveUndoStack : public QUndoStack { +class UndoStack : public QUndoStack { public: /** * @brief A wrapper for push() that either pushes if the command has children or deletes if not @@ -33,11 +33,4 @@ public: void pushIfHasChildren(QUndoCommand* command); }; -namespace olive { -/** - * @brief A static undo stack for undoable commands throughout Olive - */ -extern OliveUndoStack undo_stack; -} - #endif // UNDOSTACK_H diff --git a/app/widget/menu/menushared.cpp b/app/widget/menu/menushared.cpp index 837ae69d4..625f4ac47 100644 --- a/app/widget/menu/menushared.cpp +++ b/app/widget/menu/menushared.cpp @@ -24,18 +24,14 @@ #include "panel/panelmanager.h" #include "panel/timeline/timeline.h" -MenuShared olive::menu_shared; +MenuShared* MenuShared::instance_ = nullptr; MenuShared::MenuShared() -{ -} - -void MenuShared::Initialize() { // "New" menu shared items new_project_item_ = Menu::CreateItem(this, "newproj", nullptr, nullptr, "Ctrl+N"); - new_sequence_item_ = Menu::CreateItem(this, "newseq", &olive::core, SLOT(CreateNewSequence()), "Ctrl+Shift+N"); - new_folder_item_ = Menu::CreateItem(this, "newfolder", &olive::core, SLOT(CreateNewFolder())); + new_sequence_item_ = Menu::CreateItem(this, "newseq", Core::instance(), SLOT(CreateNewSequence()), "Ctrl+Shift+N"); + new_folder_item_ = Menu::CreateItem(this, "newfolder", Core::instance(), SLOT(CreateNewFolder())); // "Edit" menu shared items edit_cut_item_ = Menu::CreateItem(this, "cut", nullptr, nullptr, "Ctrl+X"); @@ -63,6 +59,16 @@ void MenuShared::Initialize() Retranslate(); } +void MenuShared::CreateInstance() +{ + instance_ = new MenuShared(); +} + +void MenuShared::DestroyInstance() +{ + delete instance_; +} + void MenuShared::AddItemsForNewMenu(Menu *m) { m->addAction(new_project_item_); @@ -101,6 +107,11 @@ void MenuShared::AddItemsForClipEditMenu(Menu *m) m->addAction(clip_nest_item_); } +MenuShared *MenuShared::instance() +{ + return instance_; +} + void MenuShared::SplitAtPlayhead() { TimelinePanel* timeline = PanelManager::instance()->MostRecentlyFocused(); diff --git a/app/widget/menu/menushared.h b/app/widget/menu/menushared.h index 6a172debb..5b4e9446c 100644 --- a/app/widget/menu/menushared.h +++ b/app/widget/menu/menushared.h @@ -31,7 +31,9 @@ class MenuShared : public QObject { public: MenuShared(); - void Initialize(); + static void CreateInstance(); + static void DestroyInstance(); + void Retranslate(); void AddItemsForNewMenu(Menu* m); @@ -39,6 +41,8 @@ public: void AddItemsForInOutMenu(Menu* m); void AddItemsForClipEditMenu(Menu* m); + static MenuShared* instance(); + private: // "New" menu shared items QAction* new_project_item_; @@ -68,6 +72,8 @@ private: QAction* clip_enable_disable_item_; QAction* clip_nest_item_; + static MenuShared* instance_; + private slots: void SplitAtPlayhead(); @@ -75,8 +81,4 @@ private slots: }; -namespace olive { -extern MenuShared menu_shared; -} - #endif // MENUSHARED_H diff --git a/app/widget/nodeparamview/nodeparamviewitem.cpp b/app/widget/nodeparamview/nodeparamviewitem.cpp index fb7d93bc6..e2fbff8ed 100644 --- a/app/widget/nodeparamview/nodeparamviewitem.cpp +++ b/app/widget/nodeparamview/nodeparamviewitem.cpp @@ -26,10 +26,10 @@ #include #include +#include "core.h" #include "nodeparamviewundo.h" #include "project/item/sequence/sequence.h" #include "ui/icons/icons.h" -#include "undo/undostack.h" NodeParamViewItem::NodeParamViewItem(Node *node, QWidget *parent) : QWidget(parent), @@ -260,7 +260,7 @@ void NodeParamViewItem::UserChangedKeyframeEnable(bool e) } } - olive::undo_stack.pushIfHasChildren(command); + Core::instance()->undo_stack()->pushIfHasChildren(command); } void NodeParamViewItem::UserToggledKeyframe(bool e) @@ -283,7 +283,7 @@ void NodeParamViewItem::UserToggledKeyframe(bool e) new NodeParamRemoveKeyframeCommand(input, key, command); } - olive::undo_stack.pushIfHasChildren(command); + Core::instance()->undo_stack()->pushIfHasChildren(command); } void NodeParamViewItem::InputKeyframeEnableChanged(bool e) diff --git a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp index 6f96d1073..acf5656ee 100644 --- a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp +++ b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp @@ -7,6 +7,7 @@ #include #include +#include "core.h" #include "node/node.h" #include "nodeparamviewundo.h" #include "project/item/sequence/sequence.h" @@ -262,7 +263,7 @@ void NodeParamViewWidgetBridge::SetInputValue(const QVariant &value) new NodeParamSetKeyframeValueCommand(input_->keyframes().first(), value, command); } - olive::undo_stack.pushIfHasChildren(command); + Core::instance()->undo_stack()->pushIfHasChildren(command); } void NodeParamViewWidgetBridge::WidgetCallback() diff --git a/app/widget/nodeview/nodeview.cpp b/app/widget/nodeview/nodeview.cpp index 863cb7957..aea3e0513 100644 --- a/app/widget/nodeview/nodeview.cpp +++ b/app/widget/nodeview/nodeview.cpp @@ -20,9 +20,9 @@ #include "nodeview.h" +#include "core.h" #include "nodeviewundo.h" #include "node/factory.h" -#include "undo/undostack.h" NodeView::NodeView(QWidget *parent) : QGraphicsView(parent), @@ -142,7 +142,7 @@ void NodeView::DeleteSelected() return; } - olive::undo_stack.push(new NodeRemoveCommand(graph_, selected_nodes)); + Core::instance()->undo_stack()->push(new NodeRemoveCommand(graph_, selected_nodes)); } void NodeView::AddNode(Node* node) @@ -244,6 +244,6 @@ void NodeView::CreateNodeSlot(QAction *action) Node* new_node = NodeFactory::CreateFromMenuAction(action); if (new_node) { - olive::undo_stack.push(new NodeAddCommand(graph_, new_node)); + Core::instance()->undo_stack()->push(new NodeAddCommand(graph_, new_node)); } } diff --git a/app/widget/nodeview/nodeviewitem.cpp b/app/widget/nodeview/nodeviewitem.cpp index 06cc6afa9..dd8007cdb 100644 --- a/app/widget/nodeview/nodeviewitem.cpp +++ b/app/widget/nodeview/nodeviewitem.cpp @@ -31,7 +31,6 @@ #include "nodeview.h" #include "nodeviewundo.h" #include "ui/icons/icons.h" -#include "undo/undostack.h" #include "window/mainwindow/mainwindow.h" NodeViewItem::NodeViewItem(QGraphicsItem *parent) : @@ -169,7 +168,7 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti { // HACK for getting the main QWidget palette color (the `widget`'s palette uses the NodeView color instead which we // don't want here) - QPalette app_pal = olive::core.main_window()->palette(); + QPalette app_pal = Core::instance()->main_window()->palette(); // Set up border, which will change color if selected QPen border_pen(css_proxy_.BorderColor(), node_border_width_); @@ -460,7 +459,7 @@ void NodeViewItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) dragging_edge_ = nullptr; - olive::undo_stack.pushIfHasChildren(node_edge_change_command_); + Core::instance()->undo_stack()->pushIfHasChildren(node_edge_change_command_); node_edge_change_command_ = nullptr; return; } diff --git a/app/widget/projectexplorer/CMakeLists.txt b/app/widget/projectexplorer/CMakeLists.txt index faaf3bfc4..e999f1d1d 100644 --- a/app/widget/projectexplorer/CMakeLists.txt +++ b/app/widget/projectexplorer/CMakeLists.txt @@ -18,7 +18,6 @@ set(OLIVE_SOURCES ${OLIVE_SOURCES} widget/projectexplorer/projectexplorer.h widget/projectexplorer/projectexplorer.cpp - widget/projectexplorer/projectexplorerdefines.h widget/projectexplorer/projectexplorertreeview.h widget/projectexplorer/projectexplorertreeview.cpp widget/projectexplorer/projectexplorerlistview.h diff --git a/app/widget/projectexplorer/projectexplorer.cpp b/app/widget/projectexplorer/projectexplorer.cpp index 668c5e0c6..cb53abcb0 100644 --- a/app/widget/projectexplorer/projectexplorer.cpp +++ b/app/widget/projectexplorer/projectexplorer.cpp @@ -24,12 +24,11 @@ #include #include +#include "common/define.h" #include "dialog/footageproperties/footageproperties.h" -#include "projectexplorerdefines.h" ProjectExplorer::ProjectExplorer(QWidget *parent) : QWidget(parent), - view_type_(olive::TreeView), model_(this) { // Create layout @@ -63,40 +62,40 @@ ProjectExplorer::ProjectExplorer(QWidget *parent) : AddView(icon_view_); // Set default view to tree view - set_view_type(olive::TreeView); + set_view_type(ProjectToolbar::TreeView); // Set default icon size - SizeChangedSlot(olive::kProjectIconSizeDefault); + SizeChangedSlot(kProjectIconSizeDefault); // Set rename timer timeout rename_timer_.setInterval(500); - connect(&rename_timer_, SIGNAL(timeout()), this, SLOT(RenameTimerSlot())); + connect(&rename_timer_, &QTimer::timeout, this, &ProjectExplorer::RenameTimerSlot); - connect(tree_view_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu())); - connect(list_view_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu())); - connect(icon_view_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu())); + connect(tree_view_, &ProjectExplorerTreeView::customContextMenuRequested, this, &ProjectExplorer::ShowContextMenu); + connect(list_view_, &ProjectExplorerListView::customContextMenuRequested, this, &ProjectExplorer::ShowContextMenu); + connect(icon_view_, &ProjectExplorerIconView::customContextMenuRequested, this, &ProjectExplorer::ShowContextMenu); } -const olive::ProjectViewType &ProjectExplorer::view_type() +const ProjectToolbar::ViewType &ProjectExplorer::view_type() { return view_type_; } -void ProjectExplorer::set_view_type(olive::ProjectViewType type) +void ProjectExplorer::set_view_type(ProjectToolbar::ViewType type) { view_type_ = type; // Set widget based on view type switch (view_type_) { - case olive::TreeView: + case ProjectToolbar::TreeView: stacked_widget_->setCurrentWidget(tree_view_); nav_bar_->setVisible(false); break; - case olive::ListView: + case ProjectToolbar::ListView: stacked_widget_->setCurrentWidget(list_view_); nav_bar_->setVisible(true); break; - case olive::IconView: + case ProjectToolbar::IconView: stacked_widget_->setCurrentWidget(icon_view_); nav_bar_->setVisible(true); break; @@ -172,7 +171,7 @@ void ProjectExplorer::DoubleClickViewSlot(const QModelIndex &index) // If the item is a folder, browse to it if (i->CanHaveChildren() - && (view_type() == olive::ListView || view_type() == olive::IconView)) { + && (view_type() == ProjectToolbar::ListView || view_type() == ProjectToolbar::IconView)) { BrowseToFolder(index); @@ -232,12 +231,12 @@ void ProjectExplorer::ShowContextMenu() if (selected_items.isEmpty()) { // FIXME: These are both duplicates of items from MainMenu, is there any way to re-use the code? QAction* import_action = menu.addAction(tr("&Import...")); - connect(import_action, SIGNAL(triggered(bool)), &olive::core, SLOT(DialogImportShow())); + connect(import_action, SIGNAL(triggered(bool)), Core::instance(), SLOT(DialogImportShow())); menu.addSeparator(); QAction* project_properties = menu.addAction(tr("&Project Properties...")); - connect(project_properties, SIGNAL(triggered(bool)), &olive::core, SLOT(DialogProjectPropertiesShow())); + connect(project_properties, SIGNAL(triggered(bool)), Core::instance(), SLOT(DialogProjectPropertiesShow())); } else { QAction* properties_action = menu.addAction(tr("P&roperties")); diff --git a/app/widget/projectexplorer/projectexplorer.h b/app/widget/projectexplorer/projectexplorer.h index df3f6da81..45416b49a 100644 --- a/app/widget/projectexplorer/projectexplorer.h +++ b/app/widget/projectexplorer/projectexplorer.h @@ -27,11 +27,11 @@ #include "project/project.h" #include "project/projectviewmodel.h" -#include "project/projectviewtype.h" #include "widget/projectexplorer/projectexplorericonview.h" #include "widget/projectexplorer/projectexplorerlistview.h" #include "widget/projectexplorer/projectexplorertreeview.h" #include "widget/projectexplorer/projectexplorernavigation.h" +#include "widget/projecttoolbar/projecttoolbar.h" /** * @brief A widget for browsing through a Project structure. @@ -47,7 +47,7 @@ class ProjectExplorer : public QWidget public: ProjectExplorer(QWidget* parent); - const olive::ProjectViewType& view_type(); + const ProjectToolbar::ViewType& view_type(); Project* project(); void set_project(Project* p); @@ -74,7 +74,7 @@ public: ProjectViewModel* model(); public slots: - void set_view_type(olive::ProjectViewType type); + void set_view_type(ProjectToolbar::ViewType type); void Edit(Item* item); @@ -124,7 +124,7 @@ private: ProjectExplorerListView* list_view_; ProjectExplorerTreeView* tree_view_; - olive::ProjectViewType view_type_; + ProjectToolbar::ViewType view_type_; ProjectViewModel model_; diff --git a/app/widget/projectexplorer/projectexplorerdefines.h b/app/widget/projectexplorer/projectexplorerdefines.h deleted file mode 100644 index e8d49e5e2..000000000 --- a/app/widget/projectexplorer/projectexplorerdefines.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef PROJECTEXPLORERDEFINES_H -#define PROJECTEXPLORERDEFINES_H - -namespace olive { - -/// The minimum size an icon in ProjectExplorer can be -const int kProjectIconSizeMinimum = 16; - -/// The maximum size an icon in ProjectExplorer can be -const int kProjectIconSizeMaximum = 256; - -/// The default size an icon in ProjectExplorer can be -const int kProjectIconSizeDefault = 64; - -} - -#endif // PROJECTEXPLORERDEFINES_H diff --git a/app/widget/projectexplorer/projectexplorernavigation.cpp b/app/widget/projectexplorer/projectexplorernavigation.cpp index 9f694a1ef..bc2f16416 100644 --- a/app/widget/projectexplorer/projectexplorernavigation.cpp +++ b/app/widget/projectexplorer/projectexplorernavigation.cpp @@ -23,8 +23,8 @@ #include #include +#include "common/define.h" #include "ui/icons/icons.h" -#include "widget/projectexplorer/projectexplorerdefines.h" ProjectExplorerNavigation::ProjectExplorerNavigation(QWidget *parent) : QWidget(parent) @@ -89,7 +89,7 @@ void ProjectExplorerNavigation::Retranslate() void ProjectExplorerNavigation::UpdateIcons() { dir_up_btn_->setIcon(icon::DirUp); - size_slider_->setMinimum(olive::kProjectIconSizeMinimum); - size_slider_->setMaximum(olive::kProjectIconSizeMaximum); - size_slider_->setValue(olive::kProjectIconSizeDefault); + size_slider_->setMinimum(kProjectIconSizeMinimum); + size_slider_->setMaximum(kProjectIconSizeMaximum); + size_slider_->setValue(kProjectIconSizeDefault); } diff --git a/app/widget/projectexplorer/projectexplorernavigation.h b/app/widget/projectexplorer/projectexplorernavigation.h index f49712efd..736391247 100644 --- a/app/widget/projectexplorer/projectexplorernavigation.h +++ b/app/widget/projectexplorer/projectexplorernavigation.h @@ -35,15 +35,15 @@ * * Double clicking a Folder in those views will enter that folder * * This navigation bar offers a "directory up" button for leaving a folder * - * This navbar also provides an icon size slider for those views (between olive::kProjectIconSizeMinimum and - * olive::kProjectIconSizeMaximum) as well as text that's intended to be set to the current Folder's name (or + * This navbar also provides an icon size slider for those views (between kProjectIconSizeMinimum and + * kProjectIconSizeMaximum) as well as text that's intended to be set to the current Folder's name (or * empty for the root folder). * * This widget does not actually communicate to Project or ProjectExplorer classes. It is simply UI widgets that are * intended to be connected in ways that do. This is the primarily responsibility of ProjectExplorer. * * By default, the directory up button is disabled (assuming root folder), the text is empty, and the icon size slider - * is set to olive::kProjectIconSizeDefault. + * is set to kProjectIconSizeDefault. */ class ProjectExplorerNavigation : public QWidget { diff --git a/app/widget/projecttoolbar/projecttoolbar.cpp b/app/widget/projecttoolbar/projecttoolbar.cpp index 63c359ba7..6abdf7dd1 100644 --- a/app/widget/projecttoolbar/projecttoolbar.cpp +++ b/app/widget/projecttoolbar/projecttoolbar.cpp @@ -84,16 +84,16 @@ ProjectToolbar::ProjectToolbar(QWidget *parent) : UpdateIcons(); } -void ProjectToolbar::SetView(olive::ProjectViewType type) +void ProjectToolbar::SetView(ViewType type) { switch (type) { - case olive::TreeView: + case TreeView: tree_button_->setChecked(true); break; - case olive::IconView: + case IconView: icon_button_->setChecked(true); break; - case olive::ListView: + case ListView: list_button_->setChecked(true); break; } @@ -140,11 +140,11 @@ void ProjectToolbar::ViewButtonClicked() { // Determine which view button triggered this slot and emit a signal accordingly if (sender() == tree_button_) { - emit ViewChanged(olive::TreeView); + emit ViewChanged(ProjectToolbar::TreeView); } else if (sender() == icon_button_) { - emit ViewChanged(olive::IconView); + emit ViewChanged(ProjectToolbar::IconView); } else if (sender() == list_button_) { - emit ViewChanged(olive::ListView); + emit ViewChanged(ProjectToolbar::ListView); } else { // Assert that it was one of the above buttons abort(); diff --git a/app/widget/projecttoolbar/projecttoolbar.h b/app/widget/projecttoolbar/projecttoolbar.h index 1eef6f570..b606a6018 100644 --- a/app/widget/projecttoolbar/projecttoolbar.h +++ b/app/widget/projecttoolbar/projecttoolbar.h @@ -25,8 +25,6 @@ #include #include -#include "project/projectviewtype.h" - /** * @brief The ProjectToolbar class * @@ -41,8 +39,14 @@ class ProjectToolbar : public QWidget public: ProjectToolbar(QWidget* parent); + enum ViewType { + TreeView, + ListView, + IconView + }; + public slots: - void SetView(olive::ProjectViewType type); + void SetView(ViewType type); protected: void changeEvent(QEvent *) override; @@ -57,7 +61,7 @@ signals: void SearchChanged(const QString&); - void ViewChanged(olive::ProjectViewType type); + void ViewChanged(ViewType type); private: void Retranslate(); diff --git a/app/widget/timelinewidget/timelinewidget.cpp b/app/widget/timelinewidget/timelinewidget.cpp index 4301d163c..773dc550d 100644 --- a/app/widget/timelinewidget/timelinewidget.cpp +++ b/app/widget/timelinewidget/timelinewidget.cpp @@ -256,22 +256,22 @@ void TimelineWidget::DeselectAll() void TimelineWidget::RippleToIn() { - RippleEditTo(olive::timeline::kTrimIn, false); + RippleEditTo(Timeline::kTrimIn, false); } void TimelineWidget::RippleToOut() { - RippleEditTo(olive::timeline::kTrimOut, false); + RippleEditTo(Timeline::kTrimOut, false); } void TimelineWidget::EditToIn() { - RippleEditTo(olive::timeline::kTrimIn, true); + RippleEditTo(Timeline::kTrimIn, true); } void TimelineWidget::EditToOut() { - RippleEditTo(olive::timeline::kTrimOut, true); + RippleEditTo(Timeline::kTrimOut, true); } void TimelineWidget::GoToPrevCut() @@ -382,7 +382,7 @@ void TimelineWidget::SplitAtPlayhead() } if (!blocks_to_split.isEmpty()) { - olive::undo_stack.push(new BlockSplitPreservingLinksCommand(blocks_to_split, {playhead_time})); + Core::instance()->undo_stack()->push(new BlockSplitPreservingLinksCommand(blocks_to_split, {playhead_time})); } } @@ -470,7 +470,7 @@ void TimelineWidget::DeleteSelected() DeleteSelectedInternal(blocks_to_delete, true, command); - olive::undo_stack.pushIfHasChildren(command); + Core::instance()->undo_stack()->pushIfHasChildren(command); } QList TimelineWidget::GetSelectedBlocks() @@ -492,12 +492,12 @@ QList TimelineWidget::GetSelectedBlocks() return list; } -void TimelineWidget::RippleEditTo(olive::timeline::MovementMode mode, bool insert_gaps) +void TimelineWidget::RippleEditTo(Timeline::MovementMode mode, bool insert_gaps) { rational playhead_time = Timecode::timestamp_to_time(playhead_, timebase()); rational closest_point_to_playhead; - if (mode == olive::timeline::kTrimIn) { + if (mode == Timeline::kTrimIn) { closest_point_to_playhead = 0; } else { closest_point_to_playhead = RATIONAL_MAX; @@ -507,7 +507,7 @@ void TimelineWidget::RippleEditTo(olive::timeline::MovementMode mode, bool inser Block* b = track->NearestBlockBefore(playhead_time); if (b != nullptr) { - if (mode == olive::timeline::kTrimIn) { + if (mode == Timeline::kTrimIn) { closest_point_to_playhead = qMax(b->in(), closest_point_to_playhead); } else { closest_point_to_playhead = qMin(b->out(), closest_point_to_playhead); @@ -519,7 +519,7 @@ void TimelineWidget::RippleEditTo(olive::timeline::MovementMode mode, bool inser if (closest_point_to_playhead == playhead_time) { // Remove one frame only - if (mode == olive::timeline::kTrimIn) { + if (mode == Timeline::kTrimIn) { playhead_time += timebase(); } else { playhead_time -= timebase(); @@ -548,9 +548,9 @@ void TimelineWidget::RippleEditTo(olive::timeline::MovementMode mode, bool inser } } - olive::undo_stack.pushIfHasChildren(command); + Core::instance()->undo_stack()->pushIfHasChildren(command); - if (mode == olive::timeline::kTrimIn && !insert_gaps) { + if (mode == Timeline::kTrimIn && !insert_gaps) { int64_t new_time = Timecode::time_to_timestamp(closest_point_to_playhead, timebase()); SetTimeAndSignal(new_time); @@ -639,7 +639,7 @@ void TimelineWidget::UpdateTimelineLength(const rational &length) TimelineWidget::Tool *TimelineWidget::GetActiveTool() { - return tools_.at(olive::core.tool()).get(); + return tools_.at(Core::instance()->tool()).get(); } void TimelineWidget::ViewMousePressed(TimelineViewMouseEvent *event) diff --git a/app/widget/timelinewidget/timelinewidget.h b/app/widget/timelinewidget/timelinewidget.h index 783385e84..020dddbb2 100644 --- a/app/widget/timelinewidget/timelinewidget.h +++ b/app/widget/timelinewidget/timelinewidget.h @@ -5,6 +5,7 @@ #include #include +#include "core.h" #include "timelineandtrackview.h" #include "widget/slider/timeslider.h" #include "widget/timelinewidget/timelinescaledobject.h" @@ -83,7 +84,7 @@ private: TimelineWidget* parent(); - static olive::timeline::MovementMode FlipTrimMode(const olive::timeline::MovementMode& trim_mode); + static Timeline::MovementMode FlipTrimMode(const Timeline::MovementMode& trim_mode); protected: /** @@ -147,12 +148,12 @@ private: virtual rational FrameValidateInternal(rational time_movement, const QVector &ghosts); virtual void InitiateGhosts(TimelineViewBlockItem* clicked_item, - olive::timeline::MovementMode trim_mode, + Timeline::MovementMode trim_mode, bool allow_gap_trimming); - TimelineViewGhostItem* AddGhostFromBlock(Block *block, const TrackReference& track, olive::timeline::MovementMode mode); + TimelineViewGhostItem* AddGhostFromBlock(Block *block, const TrackReference& track, Timeline::MovementMode mode); - TimelineViewGhostItem* AddGhostFromNull(const rational& in, const rational& out, const TrackReference& track, olive::timeline::MovementMode mode); + TimelineViewGhostItem* AddGhostFromNull(const rational& in, const rational& out, const TrackReference& track, Timeline::MovementMode mode); /** * @brief Validates Ghosts that are getting their in points trimmed @@ -175,11 +176,11 @@ private: private: void InitiateDrag(const TimelineCoordinate &mouse_pos); - void AddGhostInternal(TimelineViewGhostItem* ghost, olive::timeline::MovementMode mode); + void AddGhostInternal(TimelineViewGhostItem* ghost, Timeline::MovementMode mode); bool IsClipTrimmable(TimelineViewBlockItem* clip, const QList& items, - const olive::timeline::MovementMode& mode); + const Timeline::MovementMode& mode); TrackReference track_start_; bool movement_allowed_; @@ -225,7 +226,7 @@ private: virtual rational FrameValidateInternal(rational time_movement, const QVector& ghosts) override; virtual void InitiateGhosts(TimelineViewBlockItem* clicked_item, - olive::timeline::MovementMode trim_mode, + Timeline::MovementMode trim_mode, bool allow_gap_trimming) override; }; @@ -239,7 +240,7 @@ private: virtual rational FrameValidateInternal(rational time_movement, const QVector& ghosts) override; virtual void InitiateGhosts(TimelineViewBlockItem* clicked_item, - olive::timeline::MovementMode trim_mode, + Timeline::MovementMode trim_mode, bool allow_gap_trimming) override; }; @@ -252,7 +253,7 @@ private: virtual void MouseReleaseInternal(TimelineViewMouseEvent *event) override; virtual rational FrameValidateInternal(rational time_movement, const QVector& ghosts) override; virtual void InitiateGhosts(TimelineViewBlockItem* clicked_item, - olive::timeline::MovementMode trim_mode, + Timeline::MovementMode trim_mode, bool allow_gap_trimming) override; }; @@ -353,7 +354,7 @@ private: QMap block_items_; - void RippleEditTo(olive::timeline::MovementMode mode, bool insert_gaps); + void RippleEditTo(Timeline::MovementMode mode, bool insert_gaps); void SetTimeAndSignal(const int64_t& t); diff --git a/app/widget/timelinewidget/tool/add.cpp b/app/widget/timelinewidget/tool/add.cpp index f301a0328..065458b8d 100644 --- a/app/widget/timelinewidget/tool/add.cpp +++ b/app/widget/timelinewidget/tool/add.cpp @@ -61,7 +61,7 @@ void TimelineWidget::AddTool::MouseRelease(TimelineViewMouseEvent *event) ghost_->GetAdjustedIn(), command); - olive::undo_stack.push(command); + Core::instance()->undo_stack()->push(command); } parent()->ClearGhosts(); diff --git a/app/widget/timelinewidget/tool/import.cpp b/app/widget/timelinewidget/tool/import.cpp index 6e78a8d78..c4703f4df 100644 --- a/app/widget/timelinewidget/tool/import.cpp +++ b/app/widget/timelinewidget/tool/import.cpp @@ -139,7 +139,7 @@ void TimelineWidget::ImportTool::DragEnter(TimelineViewMouseEvent *event) snap_points_.append(ghost->Out()); ghost->setData(TimelineViewGhostItem::kAttachedFootage, QVariant::fromValue(stream)); - ghost->SetMode(olive::timeline::kMove); + ghost->SetMode(Timeline::kMove); parent()->AddGhost(ghost); } @@ -163,7 +163,7 @@ void TimelineWidget::ImportTool::DragMove(TimelineViewMouseEvent *event) int track_movement = event->GetCoordinates().GetTrack().index() - drag_start_.GetTrack().index(); // If snapping is enabled, check for snap points - if (olive::core.snapping()) { + if (Core::instance()->snapping()) { SnapPoint(snap_points_, &time_movement); } @@ -289,7 +289,7 @@ void TimelineWidget::ImportTool::DragDrop(TimelineViewMouseEvent *event) } } - olive::undo_stack.pushIfHasChildren(command); + Core::instance()->undo_stack()->pushIfHasChildren(command); parent()->ClearGhosts(); diff --git a/app/widget/timelinewidget/tool/pointer.cpp b/app/widget/timelinewidget/tool/pointer.cpp index 41351de5e..7b464544a 100644 --- a/app/widget/timelinewidget/tool/pointer.cpp +++ b/app/widget/timelinewidget/tool/pointer.cpp @@ -193,11 +193,11 @@ void TimelineWidget::PointerTool::MouseReleaseInternal(TimelineViewMouseEvent *e Block* b = Node::ValueToPtr(ghost->data(TimelineViewGhostItem::kAttachedBlock)); // Normal blocks work in conjunction with the gap made above - if (ghost->mode() == olive::timeline::kTrimIn || ghost->mode() == olive::timeline::kTrimOut) { + if (ghost->mode() == Timeline::kTrimIn || ghost->mode() == Timeline::kTrimOut) { // If we were trimming, we'll need to change the length // If we were trimming the in point, we'll need to adjust the media in too - if (ghost->mode() == olive::timeline::kTrimIn) { + if (ghost->mode() == Timeline::kTrimIn) { new BlockResizeWithMediaInCommand(b, ghost->AdjustedLength(), command); } else { new BlockResizeCommand(b, ghost->AdjustedLength(), command); @@ -213,7 +213,7 @@ void TimelineWidget::PointerTool::MouseReleaseInternal(TimelineViewMouseEvent *e command); } - olive::undo_stack.pushIfHasChildren(command); + Core::instance()->undo_stack()->pushIfHasChildren(command); } rational TimelineWidget::PointerTool::FrameValidateInternal(rational time_movement, const QVector& ghosts) @@ -245,7 +245,7 @@ void TimelineWidget::PointerTool::InitiateDrag(const TimelineCoordinate &mouse_p track_start_ = mouse_pos.GetTrack(); // Determine whether we're trimming or moving based on the position of the cursor - olive::timeline::MovementMode trim_mode = olive::timeline::kNone; + Timeline::MovementMode trim_mode = Timeline::kNone; // FIXME: Hardcoded number const int kTrimHandle = 10; @@ -253,21 +253,21 @@ void TimelineWidget::PointerTool::InitiateDrag(const TimelineCoordinate &mouse_p qreal mouse_x = parent()->TimeToScene(mouse_pos.GetFrame()); if (trimming_allowed_ && mouse_x < clicked_item->x() + kTrimHandle) { - trim_mode = olive::timeline::kTrimIn; + trim_mode = Timeline::kTrimIn; } else if (trimming_allowed_ && mouse_x > clicked_item->x() + clicked_item->rect().right() - kTrimHandle) { - trim_mode = olive::timeline::kTrimOut; + trim_mode = Timeline::kTrimOut; } else if (movement_allowed_) { // Some derived classes don't allow movement - trim_mode = olive::timeline::kMove; + trim_mode = Timeline::kMove; } // Gaps can't be moved, only trimmed - if (clicked_item->block()->type() == Block::kGap && trim_mode == olive::timeline::kMove) { - trim_mode = olive::timeline::kNone; + if (clicked_item->block()->type() == Block::kGap && trim_mode == Timeline::kMove) { + trim_mode = Timeline::kNone; } // Make sure we can actually perform an action here - if (trim_mode != olive::timeline::kNone) { + if (trim_mode != Timeline::kNone) { InitiateGhosts(clicked_item, trim_mode, false); } } @@ -287,7 +287,7 @@ void TimelineWidget::PointerTool::ProcessDrag(const TimelineCoordinate &mouse_po rational time_movement = mouse_pos.GetFrame() - drag_start_.GetFrame(); // Perform snapping if enabled (adjusts time_movement if it's close to any potential snap points) - if (olive::core.snapping()) { + if (Core::instance()->snapping()) { SnapPoint(snap_points_, &time_movement); } @@ -298,15 +298,15 @@ void TimelineWidget::PointerTool::ProcessDrag(const TimelineCoordinate &mouse_po // Perform movement foreach (TimelineViewGhostItem* ghost, parent()->ghost_items_) { switch (ghost->mode()) { - case olive::timeline::kNone: + case Timeline::kNone: break; - case olive::timeline::kTrimIn: + case Timeline::kTrimIn: ghost->SetInAdjustment(time_movement); break; - case olive::timeline::kTrimOut: + case Timeline::kTrimOut: ghost->SetOutAdjustment(time_movement); break; - case olive::timeline::kMove: + case Timeline::kMove: { ghost->SetInAdjustment(time_movement); ghost->SetOutAdjustment(time_movement); @@ -341,7 +341,7 @@ void TimelineWidget::PointerTool::ProcessDrag(const TimelineCoordinate &mouse_po } void TimelineWidget::PointerTool::InitiateGhosts(TimelineViewBlockItem* clicked_item, - olive::timeline::MovementMode trim_mode, + Timeline::MovementMode trim_mode, bool allow_gap_trimming) { // Convert selected items list to clips list @@ -352,8 +352,8 @@ void TimelineWidget::PointerTool::InitiateGhosts(TimelineViewBlockItem* clicked_ bool multitrim_enabled = true; // Determine if the clicked item is the earliest/latest in the track for in/out trimming respectively - if (trim_mode == olive::timeline::kTrimIn - || trim_mode == olive::timeline::kTrimOut) { + if (trim_mode == Timeline::kTrimIn + || trim_mode == Timeline::kTrimOut) { multitrim_enabled = IsClipTrimmable(clicked_item, clips, trim_mode); } @@ -367,16 +367,16 @@ void TimelineWidget::PointerTool::InitiateGhosts(TimelineViewBlockItem* clicked_ bool include_this_clip = true; if (clip_item != clicked_item - && (trim_mode == olive::timeline::kTrimIn || trim_mode == olive::timeline::kTrimOut)) { + && (trim_mode == Timeline::kTrimIn || trim_mode == Timeline::kTrimOut)) { include_this_clip = multitrim_enabled ? IsClipTrimmable(clip_item, clips, trim_mode) : false; } if (include_this_clip) { Block* block = clip_item->block(); - olive::timeline::MovementMode block_mode = trim_mode; + Timeline::MovementMode block_mode = trim_mode; if (block->type() == Block::kGap && !allow_gap_trimming) { - if (trim_mode == olive::timeline::kTrimIn) { + if (trim_mode == Timeline::kTrimIn) { // Trim the previous clip's out point instead block = block->previous(); } else { @@ -393,7 +393,7 @@ void TimelineWidget::PointerTool::InitiateGhosts(TimelineViewBlockItem* clicked_ } } -TimelineViewGhostItem* TimelineWidget::PointerTool::AddGhostFromBlock(Block* block, const TrackReference& track, olive::timeline::MovementMode mode) +TimelineViewGhostItem* TimelineWidget::PointerTool::AddGhostFromBlock(Block* block, const TrackReference& track, Timeline::MovementMode mode) { TimelineViewGhostItem* ghost = TimelineViewGhostItem::FromBlock(block, track, @@ -405,7 +405,7 @@ TimelineViewGhostItem* TimelineWidget::PointerTool::AddGhostFromBlock(Block* blo return ghost; } -TimelineViewGhostItem* TimelineWidget::PointerTool::AddGhostFromNull(const rational &in, const rational &out, const TrackReference& track, olive::timeline::MovementMode mode) +TimelineViewGhostItem* TimelineWidget::PointerTool::AddGhostFromNull(const rational &in, const rational &out, const TrackReference& track, Timeline::MovementMode mode) { TimelineViewGhostItem* ghost = new TimelineViewGhostItem(); @@ -419,20 +419,20 @@ TimelineViewGhostItem* TimelineWidget::PointerTool::AddGhostFromNull(const ratio return ghost; } -void TimelineWidget::PointerTool::AddGhostInternal(TimelineViewGhostItem* ghost, olive::timeline::MovementMode mode) +void TimelineWidget::PointerTool::AddGhostInternal(TimelineViewGhostItem* ghost, Timeline::MovementMode mode) { ghost->SetMode(mode); // Prepare snap points (optimizes snapping for later) switch (mode) { - case olive::timeline::kMove: + case Timeline::kMove: snap_points_.append(ghost->In()); snap_points_.append(ghost->Out()); break; - case olive::timeline::kTrimIn: + case Timeline::kTrimIn: snap_points_.append(ghost->In()); break; - case olive::timeline::kTrimOut: + case Timeline::kTrimOut: snap_points_.append(ghost->Out()); break; default: @@ -444,13 +444,13 @@ void TimelineWidget::PointerTool::AddGhostInternal(TimelineViewGhostItem* ghost, bool TimelineWidget::PointerTool::IsClipTrimmable(TimelineViewBlockItem* clip, const QList& items, - const olive::timeline::MovementMode& mode) + const Timeline::MovementMode& mode) { foreach (TimelineViewBlockItem* compare, items) { if (clip->Track() == compare->Track() && clip != compare - && ((compare->block()->in() < clip->block()->in() && mode == olive::timeline::kTrimIn) - || (compare->block()->out() > clip->block()->out() && mode == olive::timeline::kTrimOut))) { + && ((compare->block()->in() < clip->block()->in() && mode == Timeline::kTrimIn) + || (compare->block()->out() > clip->block()->out() && mode == Timeline::kTrimOut))) { return false; } } @@ -463,7 +463,7 @@ rational TimelineWidget::PointerTool::ValidateInTrimming(rational movement, bool prevent_overwriting) { foreach (TimelineViewGhostItem* ghost, ghosts) { - if (ghost->mode() != olive::timeline::kTrimIn) { + if (ghost->mode() != Timeline::kTrimIn) { continue; } @@ -508,7 +508,7 @@ rational TimelineWidget::PointerTool::ValidateOutTrimming(rational movement, bool prevent_overwriting) { foreach (TimelineViewGhostItem* ghost, ghosts) { - if (ghost->mode() != olive::timeline::kTrimOut) { + if (ghost->mode() != Timeline::kTrimOut) { continue; } diff --git a/app/widget/timelinewidget/tool/razor.cpp b/app/widget/timelinewidget/tool/razor.cpp index 764e2ef5f..7f60df580 100644 --- a/app/widget/timelinewidget/tool/razor.cpp +++ b/app/widget/timelinewidget/tool/razor.cpp @@ -83,7 +83,7 @@ void TimelineWidget::RazorTool::MouseRelease(TimelineViewMouseEvent *event) split_tracks_.clear(); - olive::undo_stack.push(new BlockSplitPreservingLinksCommand(blocks_to_split, {split_time})); + Core::instance()->undo_stack()->push(new BlockSplitPreservingLinksCommand(blocks_to_split, {split_time})); dragging_ = false; } diff --git a/app/widget/timelinewidget/tool/ripple.cpp b/app/widget/timelinewidget/tool/ripple.cpp index 1ea64ea80..af1318b53 100644 --- a/app/widget/timelinewidget/tool/ripple.cpp +++ b/app/widget/timelinewidget/tool/ripple.cpp @@ -34,7 +34,7 @@ void TimelineWidget::RippleTool::MouseReleaseInternal(TimelineViewMouseEvent *ev Q_UNUSED(event) // For ripple operations, all ghosts will be moving the same way - olive::timeline::MovementMode movement_mode = parent()->ghost_items_.first()->mode(); + Timeline::MovementMode movement_mode = parent()->ghost_items_.first()->mode(); QUndoCommand* command = new QUndoCommand(); @@ -62,7 +62,7 @@ void TimelineWidget::RippleTool::MouseReleaseInternal(TimelineViewMouseEvent *ev } else { // This was a Block that already existed if (ghost->AdjustedLength() > 0) { - if (movement_mode == olive::timeline::kTrimIn) { + if (movement_mode == Timeline::kTrimIn) { // We'll need to shift the media in point too new BlockResizeWithMediaInCommand(b, ghost->AdjustedLength(), command); } else { @@ -77,7 +77,7 @@ void TimelineWidget::RippleTool::MouseReleaseInternal(TimelineViewMouseEvent *ev } } - olive::undo_stack.pushIfHasChildren(command); + Core::instance()->undo_stack()->pushIfHasChildren(command); } rational TimelineWidget::RippleTool::FrameValidateInternal(rational time_movement, const QVector &ghosts) @@ -90,7 +90,7 @@ rational TimelineWidget::RippleTool::FrameValidateInternal(rational time_movemen } void TimelineWidget::RippleTool::InitiateGhosts(TimelineViewBlockItem *clicked_item, - olive::timeline::MovementMode trim_mode, + Timeline::MovementMode trim_mode, bool allow_gap_trimming) { Q_UNUSED(allow_gap_trimming) @@ -107,7 +107,7 @@ void TimelineWidget::RippleTool::InitiateGhosts(TimelineViewBlockItem *clicked_i foreach (TimelineViewGhostItem* ghost, parent()->ghost_items_) { rational ghost_ripple_point; - if (trim_mode == olive::timeline::kTrimIn) { + if (trim_mode == Timeline::kTrimIn) { ghost_ripple_point = ghost->In(); } else { ghost_ripple_point = ghost->Out(); diff --git a/app/widget/timelinewidget/tool/rolling.cpp b/app/widget/timelinewidget/tool/rolling.cpp index f87225a8e..bd92ca32b 100644 --- a/app/widget/timelinewidget/tool/rolling.cpp +++ b/app/widget/timelinewidget/tool/rolling.cpp @@ -39,7 +39,7 @@ void TimelineWidget::RollingTool::MouseReleaseInternal(TimelineViewMouseEvent *e foreach (TimelineViewGhostItem* ghost, parent()->ghost_items_) { Block* b = Node::ValueToPtr(ghost->data(TimelineViewGhostItem::kAttachedBlock)); - if (ghost->mode() == olive::timeline::kTrimIn) { + if (ghost->mode() == Timeline::kTrimIn) { if (b->previous() == nullptr) { // We'll need to insert a gap here, so we'll do a Place command instead GapBlock* gap = new GapBlock(); @@ -62,12 +62,12 @@ void TimelineWidget::RollingTool::MouseReleaseInternal(TimelineViewMouseEvent *e ghost->GetAdjustedIn(), command); } - } else if (ghost->mode() == olive::timeline::kTrimOut) { + } else if (ghost->mode() == Timeline::kTrimOut) { new BlockResizeCommand(b, ghost->AdjustedLength(), command); } } - olive::undo_stack.pushIfHasChildren(command); + Core::instance()->undo_stack()->pushIfHasChildren(command); } rational TimelineWidget::RollingTool::FrameValidateInternal(rational time_movement, const QVector &ghosts) @@ -80,7 +80,7 @@ rational TimelineWidget::RollingTool::FrameValidateInternal(rational time_moveme } void TimelineWidget::RollingTool::InitiateGhosts(TimelineViewBlockItem *clicked_item, - olive::timeline::MovementMode trim_mode, + Timeline::MovementMode trim_mode, bool allow_gap_trimming) { Q_UNUSED(allow_gap_trimming) @@ -91,11 +91,11 @@ void TimelineWidget::RollingTool::InitiateGhosts(TimelineViewBlockItem *clicked_ foreach (TimelineViewGhostItem* ghost, parent()->ghost_items_) { Block* ghost_block = Node::ValueToPtr(ghost->data(TimelineViewGhostItem::kAttachedBlock)); - if (ghost->mode() == olive::timeline::kTrimIn && ghost_block->previous() != nullptr) { + if (ghost->mode() == Timeline::kTrimIn && ghost_block->previous() != nullptr) { // Add an extra Ghost for the previous block - AddGhostFromBlock(ghost_block->previous(), ghost->Track(), olive::timeline::kTrimOut); - } else if (ghost->mode() == olive::timeline::kTrimOut && ghost_block->next() != nullptr) { - AddGhostFromBlock(ghost_block->next(), ghost->Track(), olive::timeline::kTrimIn); + AddGhostFromBlock(ghost_block->previous(), ghost->Track(), Timeline::kTrimOut); + } else if (ghost->mode() == Timeline::kTrimOut && ghost_block->next() != nullptr) { + AddGhostFromBlock(ghost_block->next(), ghost->Track(), Timeline::kTrimIn); } } } diff --git a/app/widget/timelinewidget/tool/slide.cpp b/app/widget/timelinewidget/tool/slide.cpp index 40f71b515..4bf3eb599 100644 --- a/app/widget/timelinewidget/tool/slide.cpp +++ b/app/widget/timelinewidget/tool/slide.cpp @@ -40,11 +40,11 @@ void TimelineWidget::SlideTool::MouseReleaseInternal(TimelineViewMouseEvent *eve foreach (TimelineViewGhostItem* ghost, parent()->ghost_items_) { Block* b = Node::ValueToPtr(ghost->data(TimelineViewGhostItem::kAttachedBlock)); - if (ghost->mode() == olive::timeline::kTrimIn) { + if (ghost->mode() == Timeline::kTrimIn) { new BlockResizeWithMediaInCommand(b, ghost->AdjustedLength(), command); - } else if (ghost->mode() == olive::timeline::kTrimOut) { + } else if (ghost->mode() == Timeline::kTrimOut) { new BlockResizeCommand(b, ghost->AdjustedLength(), command); - } else if (ghost->mode() == olive::timeline::kMove && b->previous() == nullptr) { + } else if (ghost->mode() == Timeline::kMove && b->previous() == nullptr) { GapBlock* gap = new GapBlock(); gap->set_length_and_media_out(ghost->InAdjustment()); new NodeAddCommand(static_cast(b->parent()), gap, command); @@ -52,7 +52,7 @@ void TimelineWidget::SlideTool::MouseReleaseInternal(TimelineViewMouseEvent *eve } } - olive::undo_stack.pushIfHasChildren(command); + Core::instance()->undo_stack()->pushIfHasChildren(command); } rational TimelineWidget::SlideTool::FrameValidateInternal(rational time_movement, const QVector &ghosts) @@ -65,7 +65,7 @@ rational TimelineWidget::SlideTool::FrameValidateInternal(rational time_movement } void TimelineWidget::SlideTool::InitiateGhosts(TimelineViewBlockItem *clicked_item, - olive::timeline::MovementMode trim_mode, + Timeline::MovementMode trim_mode, bool allow_gap_trimming) { Q_UNUSED(allow_gap_trimming) @@ -80,11 +80,11 @@ void TimelineWidget::SlideTool::InitiateGhosts(TimelineViewBlockItem *clicked_it if (ghost_block->previous() != nullptr) { // Add an extra Ghost for the previous block - AddGhostFromBlock(ghost_block->previous(), ghost->Track(), olive::timeline::kTrimOut); + AddGhostFromBlock(ghost_block->previous(), ghost->Track(), Timeline::kTrimOut); } if (ghost_block->next() != nullptr) { - AddGhostFromBlock(ghost_block->next(), ghost->Track(), olive::timeline::kTrimIn); + AddGhostFromBlock(ghost_block->next(), ghost->Track(), Timeline::kTrimIn); } } } diff --git a/app/widget/timelinewidget/tool/slip.cpp b/app/widget/timelinewidget/tool/slip.cpp index 2075998d4..f62212cdb 100644 --- a/app/widget/timelinewidget/tool/slip.cpp +++ b/app/widget/timelinewidget/tool/slip.cpp @@ -78,6 +78,6 @@ void TimelineWidget::SlipTool::MouseReleaseInternal(TimelineViewMouseEvent *even new BlockSetMediaOutCommand(b, ghost->GetAdjustedMediaIn() + b->media_length(), command); } - olive::undo_stack.pushIfHasChildren(command); + Core::instance()->undo_stack()->pushIfHasChildren(command); } diff --git a/app/widget/timelinewidget/tool/tool.cpp b/app/widget/timelinewidget/tool/tool.cpp index e61d772cf..adcfda75d 100644 --- a/app/widget/timelinewidget/tool/tool.cpp +++ b/app/widget/timelinewidget/tool/tool.cpp @@ -39,14 +39,14 @@ TimelineWidget *TimelineWidget::Tool::parent() return parent_; } -olive::timeline::MovementMode TimelineWidget::Tool::FlipTrimMode(const olive::timeline::MovementMode &trim_mode) +Timeline::MovementMode TimelineWidget::Tool::FlipTrimMode(const Timeline::MovementMode &trim_mode) { - if (trim_mode == olive::timeline::kTrimIn) { - return olive::timeline::kTrimOut; + if (trim_mode == Timeline::kTrimIn) { + return Timeline::kTrimOut; } - if (trim_mode == olive::timeline::kTrimOut) { - return olive::timeline::kTrimIn; + if (trim_mode == Timeline::kTrimOut) { + return Timeline::kTrimIn; } return trim_mode; @@ -97,7 +97,7 @@ void AttemptSnap(const QList& proposed_pts, rational TimelineWidget::Tool::ValidateFrameMovement(rational movement, const QVector ghosts) { foreach (TimelineViewGhostItem* ghost, ghosts) { - if (ghost->mode() != olive::timeline::kMove) { + if (ghost->mode() != Timeline::kMove) { continue; } @@ -115,7 +115,7 @@ int TimelineWidget::Tool::ValidateTrackMovement(int movement, const QVector